问题描述:

I'm successfully loading jQuery (when setting require.config)...

// For details see:

// http://groups.google.com/group/requirejs/browse_thread/thread/e7532b7e3013bc62/1e5ca8a89b276de6?show_docid=1e5ca8a89b276de6

require.config({

paths : {

'jquery' : 'Utils/jquery'

}

});

I have a github repo with the entire set-up here: https://github.com/Integralist/RequireJs-Example

My issue is that when I try to run the build script: https://github.com/Integralist/RequireJs-Example/blob/master/Assets/Scripts/app.build.js it chokes on locating jQuery, and gives the following error...

Error: Error: Error evaluating module "undefined" at location "/Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/project-build/Assets/Scripts/jquery.js":

Error: EBADF, Bad file descriptor '/Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/project-build/Assets/Scripts/jquery.js'

fileName:/Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/project-build/Assets/Scripts/jquery.js

lineNumber: undefined

http://requirejs.org/docs/errors.html#defineerror

In module tree:

main

App/people

at Function.onError (/Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/r.js:7341:23)

at execManager (/Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/r.js:592:28)

at /Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/r.js:620:25

at execManager (/Users/stormcreative/Dropbox/Library/JavaScript/Libraries/RequireJs/Assets/Scripts/r.js:597:17)

...any ideas on how I can fix this? It appears to be trying to find jQuery in the main /Assets/Scripts/ folder but it's actually in /Assets/Scripts/Utils/jquery.js

Look forward to your help.

Kind regards,

Mark

网友答案:

you need to set the paths config on the app.build.js as well, the optimizer doesn't parse the require.config() settings contained inside the modules, it increases the flexibility of the build tool, you can easily swap modules during build or not include a module by passing the special module path "empty:".

if you look at the error message you will see that it is trying to locate jquery at /Assets/Scripts/jquery.js while the correct path is /Assets/Scripts/Utils/jquery.js.

cheers.

相关阅读:
Top