2011-10-28 53 views
3

我成功加載的jQuery(設置require.config時)...RequireJs構建腳本未能找到jQuery的

// 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) 

...我如何在f任何想法這是什麼?它似乎試圖找到主/Assets/Scripts/文件夾中的jQuery,但它實際上是在/Assets/Scripts/Utils/jquery.js

期待您的幫助。

親切的問候, 馬克

回答

4

你需要設置配置上app.build.js以及路徑,優化器不會解析包含的模塊內設置require.config(),它增加了構建工具的靈活性,您可以在構建過程中輕鬆地交換模塊,也可以通過傳遞特殊的模塊路徑"empty:"來不包含模塊。

如果你看看錯誤信息,你會發現它試圖找到jQuery的/Assets/Scripts/jquery.js而正確的路徑是/Assets/Scripts/Utils/jquery.js

歡呼聲。

+1

謝謝! spot on :-) – Integralist

+0

同意...非常有幫助! – jcreamer898

+0

我認爲你的意思是「空的:」。那個冒號讓所有的不同。 –