更新:我尝试了下面的Jeff Barczewski的答案,虽然我不再收到插件的错误,但我现在得到一个不同的错误:
Error: TypeError: Cannot read property 'normalize' of undefined
In module tree:
mymodule/core
at Object.<anonymous> (/usr/local/lib/node_modules/requirejs/bin/r.js:1193:35)
Run Code Online (Sandbox Code Playgroud)
更新2: 由于Jeff是正确的,Dojo的插件与RequireJS不兼容,我决定转而使用grunt-dojo来构建dojo.我仍然使用RequireJS作为我自己的代码,并简单地覆盖要忽略的dojo依赖项.
原帖:
我正在尝试使用grunt编译单个JS文件,以降低浏览器需要进行的HTTP请求.由于Dojo 1.9符合AMD标准,我认为我会使用Grunt的requirejs插件来优化我的代码.但是,我在使用Grunt插件和直接使用r.js时收到以下错误:
>> Tracing dependencies for: mymodule/core
>> TypeError: Cannot call method 'createElement' of undefined
>> In module tree:
>> mymodule/core
>> dojo/behavior
>> dojo/query
>> dojo/selector/_loader
{ [Error: TypeError: Cannot call method 'createElement' of undefined
In module tree:
mymodule/core
dojo/behavior
dojo/query
dojo/selector/_loader
at eval (eval at <anonymous> (/Users/EugeneZ/Workspace/presentment/web/js/node_modules/grunt-contrib-requirejs/node_modules/requirejs/bin/r.js:23690:38), <anonymous>:6:24)
]
originalError:
{ [TypeError: Cannot call method …
Run Code Online (Sandbox Code Playgroud)