TypeError: require.config is not a function

I am using require.js as part of the brunch project. This code throws an error:

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

Does this mean that requirejs is not getting into the project correctly?

+6
source share
1 answer

If you get this error, it could be like this:

  • RequireJS is not loading.

    This can be diagnosed by opening the browser debugger in order to look at network requests and see if the browser, which determines the require browser, requests and checks that the response indicates that the data is available (i.e., downloaded from the server, downloaded from the cache).

  • RequireJS loads, but does not initialize correctly.

    This can happen if something loads before RequireJS and somehow gets confused with the JavaScript runtime in such a way that RequireJS cannot be initialized. For example, if something places a global define name of any type in the global space or a global name with the name requirejs and which is a function, then RequireJS will silently refuse to initialize.

    I would diagnose this with checkpoints in a file that contains RequireJS to see if it completes execution or not.

  • RequireJS loads, but something else overrides require .

    I would check the value of require immediately after loading RequireJS. If it has a config method defined at this point, then something else should be messing with it later.

+12
source

All Articles