2015-03-02 408 views
1

我的Grunt安装发生了一些事情,我不知道它是什么。我正在使用Yeoman来支撑我的应用程序,但是今天我开始收到很多Grunt错误。举例来说,我现在得到如下当我运行Grunt Test如何在yeoman项目中重新安装Grunt?

Loading "autoprefixer.js" tasks...ERROR 
>> Error: Cannot find module 'base64-js' 
Loading "connect.js" tasks...ERROR 
>> Error: Cannot find module 'cookie-signature' 
Loading "imagemin.js" tasks...ERROR 
>> Error: Cannot find module './lib/js-yaml.js' 
Loading "jshint.js" tasks...ERROR 
>> Error: Cannot find module 'jshint' 
Loading "uglify.js" tasks...ERROR 
>> Error: Cannot find module './source-map/source-map-generator' 
Loading "cdnify.js" tasks...ERROR 
>> SyntaxError: /Users/Documents/Git/client/node_modules/grunt-google-cdn/node_modules/google-cdn/node_modules/cdnjs-cdn-data/external/cdnjs.json: Unexpected end of input 
Loading "grunt-karma.js" tasks...ERROR 
>> SyntaxError: /Users/Documents/Git/client/node_modules/karma/node_modules/socket.io/node_modules/engine.io/lib/server.js:390 
>> }); 
>>  
>> Unexpected end of input 
Loading "ngmin.js" tasks...ERROR 
>> Error: Cannot find module 'estraverse' 
Loading "svgmin.js" tasks...ERROR 
>> SyntaxError: /Users/Documents/Git/client/node_modules/grunt-svgmin/node_modules/svgo/node_modules/js-yaml/lib/js-yaml/loader.js:950 
>> }); 
>>^
>> Unexpected token) 
Loading "usemin.js" tasks...ERROR 
>> SyntaxError: /Users/Documents/Git/client/node_modules/grunt-usemin/node_modules/lodash/dist/lodash.js:5520 
>> }); 
>>^
>> Unexpected token } 
Loading "css_sprite.js" tasks...ERROR 
>> Error: Cannot find module 'async' 
Warning: Task "autoprefixer" not found. Use --force to continue. 

我已经更新NPM,我试图更新咕噜,我试图安装所有那些兽人无法找到包。有没有一种方法来核实和重新安装Grunt并为这个项目安装一个全新的副本?

回答

2

只要按照上面的错误信息......对于例如你的...

警告:找不到任务“autoprefixer”。使用--force继续。

尝试安装咕噜-autoprefixer ...

npm install grunt-autoprefixer --save 

然后运行grunt test再次...

你得到其他错误信息......找到丢失的东西...安装它通过npm。有时您可能需要谷歌的正确的包名......

缓存你的机器上
+0

起初,我以为我会做,但所有的“失踪”包的实际安装。另外,我试着运行'npm install'来重新安装它们,但没有任何改变。 – Startec 2015-03-02 06:14:38

+0

你的第一个错误是无法找到模块'base64-js' ...从那里开始... – deostroll 2015-03-02 06:25:18

8

您可能已部分安装的NPM包。

尝试运行npm cache clean

然后删除安装项目包: rm -rf node_modules

然后尝试运行npm install一次。

+0

这解决了我的问题 - npm更新失败后,我对npm有了一些幻想。以上步骤奏效,谢谢艾萨克 – 2015-08-10 16:07:05