Skip to content Skip to sidebar Skip to footer

Requirejs Module Name "requirejs" Has Not Been Loaded Yet For Context. Use Require([])

I know there is a help page for a module not loading, however, this seems like a different case due to the fact that requirejs cannot find requirejs. I installed all of my dependen

Solution 1:

The code you are showing that does var requirejs = require('requirejs'); is meant to be run in Node.js, not in a browser. Also note the configuration passed to requirejs.config which includes nodeRequire, which only makes sense in Node.js.

When you load that code in a browser with the script tag that you show, RequireJS is already loaded, and the require call tries to load it again, which is bad no matter how you cut it. It happens to trigger a RequireJS-specific error but that's a side-effect of trying to load code written for Node.js through RequireJS.

When you load the same code in Node.js, the require call is handled by Node.js. It load RequireJS and then you can configure it and use it.

Post a Comment for "Requirejs Module Name "requirejs" Has Not Been Loaded Yet For Context. Use Require([])"