我正在使用Ubuntu 14.04服务器并尝试安装grunt& grunt-cli使用此命令:
npm install -g grunt grunt-cli
一切都很好,没有错误收到。但是当我运行标准的grunt命令时,我收到了这个错误:
module.js:338
throw err;
^
Error: Cannot find module 'eventemitter2'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/var/www/html/unsplit/node_modules/grunt/lib/grunt/event.js:13:21)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at gRequire (/var/www/html/unsplit/node_modules/grunt/lib/grunt.js:23:24)
at Object.<anonymous> (/var/www/html/unsplit/node_modules/grunt/lib/grunt.js:35:1)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/usr/local/lib/node_modules/grunt-cli/bin/grunt:45:1)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3`
导致这种情况发生的原因是什么?
答案 0 :(得分:2)
出于一些奇怪的原因,我跑了一次:
npm remove -g grunt grunt-cli
并重新跑:
npm install -g grunt grunt-cli
一切正常!