user1508519
user1508519

Reputation:

RequireJS is undefined

After much frustration, I finally decided to install requirejs via npm. However, even with this basic example, it still won't work.

define(function(require) {

var requirejs = require('node/node/lib/node_modules/npm/node_modules/requirejs/require');

requirejs.config({
    //Pass the top-level main.js/index.js require
    //function to requirejs so that node modules
    //are loaded relative to the top-level JS file.
    nodeRequire: require
});

requirejs(['http'],
function   (http) {
// code here
});


});

The error:

TypeError: requirejs is undefined @ test.js:7

If I replace the long path with just require, I get instead:

 TypeError: requirejs.config is not a function @ test.js:11

Upvotes: 1

Views: 976

Answers (1)

thtsigma
thtsigma

Reputation: 4938

You created a function with an argument of require. Try changing your first line to function(somethingElse) and it should load.

Upvotes: 1

Related Questions