最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - TypeError: require.config is not a function - Stack Overflow

programmeradmin0浏览0评论

I am using require.js as part of a brunch project. This code is throwing the error:

;require.config({ // require.config is not a function
paths: {
   jquery: "lib/jquery",
   underscore: "lib/underscore",
   backbone: "lib/backbone",
   localstorage: "lib/backbone.localStorage"
}
}); 

Does that mean that requirejs is not getting included properly in the project?

I am using require.js as part of a brunch project. This code is throwing the error:

;require.config({ // require.config is not a function
paths: {
   jquery: "lib/jquery",
   underscore: "lib/underscore",
   backbone: "lib/backbone",
   localstorage: "lib/backbone.localStorage"
}
}); 

Does that mean that requirejs is not getting included properly in the project?

Share Improve this question edited Dec 17, 2014 at 8:16 ye9ane 2,0093 gold badges20 silver badges31 bronze badges asked Jan 2, 2014 at 4:01 bernie2436bernie2436 23.9k54 gold badges156 silver badges250 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 18

If you get that error, it could be that:

  • RequireJS is not loaded.

    This can diagnosed by opening the browser's debugger to look at network requests and seeing whether the file that defines require is asked by the browser and checking that the response indicates that the data is available (i.e. loaded from the server, loaded from cache).

  • RequireJS is loaded but not initializing properly.

    This could happen if something is loaded before RequireJS and somehow messes with the JavaScript runtime in a way that makes RequireJS fail to initialize. For instance, if something puts in the global space a global named define of any type, or global named requirejs and which is a function, then RequireJS will silently abandon initializing.

    I'd diagnose this with breakpoints in the file that contains RequireJS to see whether it completes execution or not.

  • RequireJS is loaded but something else redefines require.

    I'd inspect the value of require just after RequireJS is loaded. If it has a config method defined at that point, then something else must be messing with it later.

发布评论

评论列表(0)

  1. 暂无评论