我正在成功加载jQuery(设置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'
}
});
我在这里有一个完整设置的github回购:https://github.com/Integralist/RequireJs-Example
我的问题是,当我尝试运行构建脚本时:https://github.com/Integralist/RequireJs-Example/blob/master/Assets/Scripts/app.build.js它会在定位jQuery时遇到麻烦,并给出以下错误...
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)
......关于我如何解决这个问题的任何想法?它似乎试图在主/Assets/Scripts/
文件夹中找到jQuery,但它实际上在/Assets/Scripts/Utils/jquery.js
期待您的帮助。
亲切的问候, 标记
答案 0 :(得分:4)
你需要在app.build.js
上设置路径配置,优化器不会解析模块中包含的require.config()
设置,它增加了构建工具的灵活性,你可以轻松在构建期间交换模块或不通过传递特殊模块路径"empty:"
来包含模块。
如果您查看错误消息,您会看到它正在尝试在/Assets/Scripts/jquery.js
找到jquery,而正确的路径为/Assets/Scripts/Utils/jquery.js
。
欢呼声。