2015-03-02 405 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