无法使用npm命令行安装grunt

3

我的Node版本是v6.6.0。 我的npm版本是v4.0.5。

使用npm ls -g已经发现grunt-cli已安装。

然而,当我使用npm install grunt -save-dev时,它显示:

SuoYong:grunt suoyong$ npm install grunt --save-dev
npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/Cellar/node/6.6.0/bin/node" "/usr/local/bin/npm" "install" "grunt" "--save-dev"
npm ERR! node v6.6.0
npm ERR! npm  v4.0.5
npm ERR! code ENOSELF

npm ERR! Refusing to install package with name "grunt" under a package
npm ERR! also called "grunt". Did you name your project the same
npm ERR! as the dependency you're installing?
npm ERR! 
npm ERR! For more information, see:
npm ERR!     <https://docs.npmjs.com/cli/install#limitations-of-npms-install-algorithm>
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/suoyong/Node/grunt/npm-debug.log

我已经花费两个小时检查这个简单的问题,但是还没有解决。谢谢。

3个回答

4
我已解决此问题,因为我的package.json名称与grunt名称相同。感谢stackoverflow社区提供的帮助。

1
问题出在你的package.json文件中。你需要改变名字。
"name": "grunt"中,将grunt改成其他名称,它就能完美工作了。

0

我遇到了同样的问题。我重命名了文件夹(GitBash 所在的文件夹),并解决了问题。 文件夹原本名字叫 "grunt",我把它改成了 "grunt-typescript",然后再试了一次。

  • npm install grunt --save

成功了! :)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接