如何在 yeoman 项目中重新安装 Grunt?
How can I reinstall Grunt in a yeoman project?
我的 G运行t 安装出现问题,我不知道是什么原因。我正在使用 Yeoman 构建我的应用程序,但今天我开始收到许多 G运行t 错误。例如,当我 运行 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,我尝试更新 G运行t,我尝试安装所有 G运行t 找不到的包。有没有办法核对并重新铺设 G运行t 并为这个项目安装一个全新的副本?
只需按照错误消息...例如你的说...
Warning: Task "autoprefixer" not found. Use --force to continue.
尝试安装 g运行t-autoprefixer...
npm install grunt-autoprefixer --save
然后 运行 再 grunt test
...
您收到其他错误消息...找到缺少的东西...通过 npm 安装它。有时您可能需要 google 才能获得正确的包名称...
您可能已经部分安装了缓存在计算机上的 npm 包。
尝试运行npm cache clean
然后删除安装的项目包:
rm -rf node_modules
然后再试一次 运行 npm install
。
我的 G运行t 安装出现问题,我不知道是什么原因。我正在使用 Yeoman 构建我的应用程序,但今天我开始收到许多 G运行t 错误。例如,当我 运行 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,我尝试更新 G运行t,我尝试安装所有 G运行t 找不到的包。有没有办法核对并重新铺设 G运行t 并为这个项目安装一个全新的副本?
只需按照错误消息...例如你的说...
Warning: Task "autoprefixer" not found. Use --force to continue.
尝试安装 g运行t-autoprefixer...
npm install grunt-autoprefixer --save
然后 运行 再 grunt test
...
您收到其他错误消息...找到缺少的东西...通过 npm 安装它。有时您可能需要 google 才能获得正确的包名称...
您可能已经部分安装了缓存在计算机上的 npm 包。
尝试运行npm cache clean
然后删除安装的项目包:
rm -rf node_modules
然后再试一次 运行 npm install
。