【发布时间】:2017-11-04 11:41:03
【问题描述】:
以下是我的代码:-
projectDependencies.forEach((val)=>
{
container.register(val[0],function ()
{
return require(val[1]);
});
});
当我运行命令 nodemon server.js 时,我收到以下错误:
Error: could not parse function arguments: ()=>
{
return container;
}
at argList (C:\Users\Data-Vinci\Desktop\JS\chatapp\node_modules\dependable\index.js:97:15)
at toFactory (C:\Users\Data-Vinci\Desktop\JS\chatapp\node_modules\dependable\index.js:82:21)
at registerOne (C:\Users\Data-Vinci\Desktop\JS\chatapp\node_modules\dependable\index.js:33:32)
at Object.register (C:\Users\Data-Vinci\Desktop\JS\chatapp\node_modules\dependable\index.js:26:16)
at Object.<anonymous> (C:\Users\Data-Vinci\Desktop\JS\chatapp\container.js:22:11)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
我认为我的代码在语法上是正确的。不知道问题出在哪里。
注意:- 但是,如果我使用 function() 而不是 ()=> 则一切正常。
【问题讨论】:
标签: javascript node.js express ecmascript-6