RequireJs 构建脚本无法找到 jQuery

发布于 2024-12-12 17:14:07 字数 1913 浏览 3 评论 0原文

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

期待您的帮助。

亲切的问候, 标记

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月亮坠入山谷 2024-12-19 17:14:07

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

如果您查看错误消息,您会发现它正在尝试在 /Assets/Scripts/jquery.js 中定位 jquery,而正确的路径是 /Assets/Scripts/Utils/jquery。 js

干杯。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文