Gruntjs 无法使用npm命令行安装grunt

Gruntjs 无法使用npm命令行安装grunt,gruntjs,Gruntjs,我的节点版本是v6.6.0。 我的npm版本是v4.0.5 使用npm ls-g已发现grunt cli已安装 但是,当我使用npm安装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" "

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

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

但是,当我使用npm安装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
SuoYong:grunt SuoYong$npm安装grunt--保存开发
npm错误!达尔文15.3.0
npm错误!argv“/usr/local/ceral/node/6.6.0/bin/node”“/usr/local/bin/npm”“安装”“grunt”“--保存开发”
npm错误!节点v6.6.0
npm错误!npm v4.0.5
npm错误!代码ENOSELF
npm错误!拒绝在包下安装名为“grunt”的包
npm错误!也称为“咕噜”。你给你的项目起了同样的名字吗
npm错误!作为要安装的依赖项?
npm错误!
npm错误!有关详细信息,请参阅:
npm错误!
npm错误!
npm错误!如果需要帮助,您可以在以下位置报告此错误:
npm错误!
npm错误!请在任何支持请求中包括以下文件:
npm错误/Users/suoyong/Node/grunt/npm-debug.log
我已经检查了两个小时这个简单的问题。但这并不能解决问题。
谢谢

我已经解决了这个问题,因为我的package.json名称与grunt名称相同。谢谢stackoverflow space。

问题在package.json文件中。你应该改名


“name”:“grunt”
中,将grunt设置为其他值,它应该可以正常工作。

我也有同样的问题。我重命名了文件夹(我运行GitBash的文件夹)的名称并修复了它。 文件夹的名称是“grunt”,我将其更改为“grunt typescript”,然后重试

  • npm安装grunt--保存
我工作过!:)