简体   繁体   English

如何在Yeeoman项目中重新安装Grunt?

[英]How can I reinstall Grunt in a yeoman project?

Something happened to my Grunt installation, and I have no idea what it was. 我的Grunt安装发生了什么事,我不知道它是什么。 I am using Yeoman to scaffold my app, but today I started getting many Grunt errors. 我正在使用Yeoman搭建我的应用程序,但是今天我开始遇到很多Grunt错误。 For instance, I now get the following when I run Grunt Test : 例如,当我运行Grunt Test时,我得到以下信息:

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.

I have updated NPM, I have tried to update Grunt, I have tried to install all of those packages that Grunt can not find. 我已更新NPM,已尝试更新Grunt,已尝试安装Grunt找不到的所有那些软件包。 Is there a way to nuke and repave Grunt and install a brand new copy for this project? 有没有办法核对并重新保存Grunt并为此项目安装全新的副本?

You might have partially installed npm packages cached on your machine. 您可能已部分安装了缓存在计算机上的npm软件包。

Try running npm cache clean 尝试运行npm cache clean

Then delete the project packages installed: rm -rf node_modules 然后删除安装的项目包: rm -rf node_modules

Then try running npm install one more time. 然后尝试再次运行npm install

Just follow the error messages...for eg yours say... 只需按照错误消息进行操作即可,例如您说的话...

Warning: Task "autoprefixer" not found. 警告:找不到任务“ autoprefixer”。 Use --force to continue. 使用--force继续。

Try installing grunt-autoprefixer... 尝试安装grunt-autoprefixer ...

npm install grunt-autoprefixer --save

Then run grunt test again... 然后再次运行grunt test ...

You get other error messages...find the stuff that is missing...install it via npm. 您会收到其他错误消息...找到缺少的内容...通过npm安装它。 At times you may have to google for the correct package names... 有时您可能必须用Google搜索正确的软件包名称...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM