This question already has an answer here:
- Trouble combining Require.js and Backbone.js/Underscore.js 3 answers
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?