Magento – Uncaught ReferenceError: config is not defined magento 2

magento2requirejs

I'm getting an error in the console and it says:

Uncaught ReferenceError: config is not defined.

The file it relates to is requirejs-config.js:1149 but I have no idea what this relates to or how to fix it. Any ideas?

The code in question is:

})(require);
require.config(config);
})();

Best Answer

You probably have a requirejs-config.js file somewhere in your codebase that is empty. Magento includes every requirejs-config.js file it finds, but it does expect it to contain a config object.

In terminal, in your Magento root, run;

find . -type f -iname requirejs-config.js | xargs ls -1lathr

Look for files that are 0 bytes. Either remove those files or place an empty config object in it;

var config = {};

That should fix it.

Related Topic