如何解决安装grunt-contrib-uglify的错误

时间:2014-05-22 11:53:05

标签: node.js gruntjs

我试图安装模块grunt-contrib-uglify并最终出现以下错误:

[james@linux tmp]npm install grunt-contrib-uglify --save-dev
npm WARN package.json example-project@0.1.0 No description
npm WARN package.json example-project@0.1.0 No repository field.
npm WARN package.json example-project@0.1.0 No README data
npm http GET https://registry.npmjs.org/grunt-contrib-uglify
npm http 200 https://registry.npmjs.org/grunt-contrib-uglify
npm http GET https://registry.npmjs.org/grunt-contrib-uglify/-/grunt-contrib-uglify-0.4.0.tgz
npm http 200 https://registry.npmjs.org/grunt-contrib-uglify/-/grunt-contrib-uglify-0.4.0.tgz
npm http GET https://registry.npmjs.org/uglify-js
npm http GET https://registry.npmjs.org/maxmin
npm http GET https://registry.npmjs.org/chalk
npm http 304 https://registry.npmjs.org/chalk
npm ERR! Error: No compatible version found: chalk@'^0.4.0'
npm ERR! Valid install targets:
npm ERR! ["0.1.0","0.1.1","0.2.0","0.2.1","0.3.0","0.4.0"]
npm ERR!     at installTargetsError (/usr/local/lib/node_modules/npm/lib/cache.js:719:10)
npm ERR!     at /usr/local/lib/node_modules/npm/lib/cache.js:638:10
npm ERR!     at saved (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/get.js:142:7)
npm ERR!     at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:133:7
npm ERR!     at Object.oncomplete (fs.js:107:15)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Linux 2.6.32-358.el6.x86_64
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "grunt-contrib-uglify" "--save-dev"
npm ERR! cwd /export/home/james/tmp
npm ERR! node -v v0.10.15
npm ERR! npm -v 1.3.5
npm http 200 https://registry.npmjs.org/uglify-js
npm http 200 https://registry.npmjs.org/maxmin
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /export/home/james/tmp/npm-debug.log
npm ERR! not ok code 0

这是什么线索?

1 个答案:

答案 0 :(得分:2)

尝试如下:

 1) npm install -g grunt-cli

这会将grunt命令放在您的系统路径中,允许它从任何目录运行。

请注意,安装grunt-cli不会安装Grunt任务运行器! Grunt CLI的工作很简单:运行已安装在Gruntfile旁边的Grunt版本。这允许多个版本的Grunt同时安装在同一台机器上。

 2) npm install grunt --save-dev 

将Grunt和gruntplugins添加到现有package.json的最简单方法是使用命令npm install --save-dev。这不仅会在本地安装,而且会使用波浪号版本范围自动添加到devDependencies部分。

如需进一步帮助,请点击此链接

http://gruntjs.com/getting-started