3

我已成功加载 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

期待您的帮助。

亲切的问候,马克

4

1 回答 1

4

您还需要设置路径配置app.build.js,优化器不会解析require.config()模块中包含的设置,它增加了构建工具的灵活性,您可以在构建期间轻松交换模块或通过传递特殊的不包含模块模块路径"empty:"

如果您查看错误消息,您将看到它试图在/Assets/Scripts/jquery.js正确路径为/Assets/Scripts/Utils/jquery.js.

干杯。

于 2011-10-28T11:26:46.193 回答