Reputation: 313
Seeing error - I'm not sure what exactly is wrong. Page/Modules loads sometimes but many a times I get this error. This is with latest underscore and backbone modules.
Error: Module name 'underscore' has not been loaded yet for context: _ http://requirejs.org/docs/errors.html#notloaded
require.config({
"baseUrl": "js",
"paths": {
"jquery":"libs/jquery-1.8.2",
"underscore":"libs/underscore-min",
"backbone":"libs/backbone-min",
},
shim: {
'backbone': {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
'underscore': {
exports: '_'
}
} // end Shim Configuration
});
require(['jquery', 'underscore','backbone'], function($, _, Backbone){
console.log('require init - ' + Backbone + ", " + _);
});
Upvotes: 1
Views: 581
Reputation: 3455
Try with underscore-amd version. Here is my require config and it works great:
require.config({
paths: {
"handlebars": "./libs/handlebars/handlebars",
"jquery": "./libs/jquery/jquery",
"underscore": "./libs/underscore-amd/underscore",
"backbone": "./libs/backbone-amd/backbone"
},
shim: {
"backbone": {
exports: "backbone"
},
"Handlebars": {
exports:"Handlebars"
},
"underscore": {
exports: "_"
}
}
});
As you can see I don't have base url and deps - require will find dependencies by the provided paths.
Upvotes: 3