requirejs: Module name "underscore" has not been loaded yet for context
backbone.js, javascript, jquery, requirejs, underscore.js
Solution
try this:
shim: {
jquery: {
exports: '$'
},
underscore: {
deps:["jquery"],
exports: '_'
},
backbone: {
deps:["jquery"],
exports: 'Backbone'
}
}
Problem
I always get this error when I freshly load my app, ``` Error: Module name "underscore" has not been loaded yet for context: _. Use require([]) http://requirejs.org/docs/errors.html#notloaded ...,h){c=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+b);c.requireType=b;c.re... require.js (line 8) TypeError: Backbone.Model is undefined var ProjectModel = Backbone.Model.extend({ ``` But then they are gone when I hit the refresh button on my browser. Does anyone know why? How can I fix it? This is my config/ main/ entry js file, ``` require.config({ //By default load any module IDs from js/lib baseUrl: 'js', paths: { jquery: 'lib/jquery/jquery-min', underscore: 'lib/underscore/underscore-min', backbone: 'lib/backbone/backbone-min', text: 'lib/text/text' }, shim: { jquery: { exports: '$' }, underscore: { exports: '_' }, backbone: { exports: 'Backbone' } } }); require([ // Load our app module and pass it to our definition function 'app', 'jquery', 'underscore', 'backbone', // Pull in the Collection module. 'collection/contacts' ], function(App){ // The "app" dependency is passed in as "App" App.initialize(); }); ``` Have I missed something?