javascript - 如何在 yeoman 项目中重新安装 Grunt?

标签 javascript node.js gruntjs npm yeoman

我的 Grunt 安装出现问题,我不知道是什么原因。我正在使用 Yeoman 构建我的应用程序,但今天我开始收到许多 Grunt 错误。例如,我现在在运行 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.

我已经更新了 NPM,我已经尝试更新 Grunt,我已经尝试安装所有那些 Grunt 找不到的包。有没有办法对 Grunt 进行 nuke 和 repave 并为这个项目安装一个全新的副本?

最佳答案

你可能已经部分安装了缓存在你机器上的 npm 包。

尝试运行 npm cache clean

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

然后尝试再次运行 npm install

关于javascript - 如何在 yeoman 项目中重新安装 Grunt?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28803373/

相关文章:

JavaScript 函数原型(prototype)?

javascript - 日历没有出现在它应该出现的地方! jQuery

javascript - 如何在strongloop弧中更改主机

javascript - 如何从node.js调用JSON中的数组字段

javascript - 如何在 grunt 中更改项目的版本,但从我的项目中的文件的更改

javascript - 在 IIFE 中用 global 替换 window 可以吗?

javascript - 查询字符串的正则表达式

angularjs - AWS文件上传超过5mb-nodejs

css - 只用 grunt 观察 css 变化

node.js - process.env 不包含 Heroku 上的配置变量