我正在尝试创建我的grunt构建,但坚持跟随错误
npm WARN package.json Dependency 'grunt' exists in both dependencies and devDependencies, using 'grunt@~0.4.2' from dependencies
npm ERR! Darwin 13.4.0
npm ERR! argv "node" "/usr/local/bin/npm" "install"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! code EPEERINVALID
npm ERR! peerinvalid The package grunt does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer grunt-contrib-requirejs@0.4.4 wants grunt@~0.4.0
npm ERR! peerinvalid Peer grunt-config@0.1.8 wants grunt@~0.4.0
npm ERR! peerinvalid Peer grunt-string-replace@0.2.8 wants grunt@~0.4.1
npm ERR! peerinvalid Peer grunt-contrib-clean@0.5.0 wants grunt@~0.4.0
npm ERR! peerinvalid Peer grunt-contrib-cssmin@0.10.0 wants grunt@~0.4.1
npm ERR! peerinvalid Peer grunt-contrib-jshint@0.11.0 wants grunt@~0.4.5
npm ERR! peerinvalid Peer grunt-contrib-uglify@0.8.0 wants grunt@>=0.4.0
npm ERR! peerinvalid Peer grunt-exec@0.4.6 wants grunt@~0.4
正如here提到的那样,我卸载了我的节点,npm和grunt并重新安装它们但仍面临同样的问题?
有什么想法吗?
我的JSON依赖项是:
"dependencies": {
"grunt": "~0.4.2",
"grunt-contrib-requirejs": "~0.4.1",
"grunt-config": "~0.1.4",
"grunt-string-replace": "~0.2.7",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-cssmin": "~0.10.0"
},
"devDependencies": {
"grunt": "0.4.2",
"grunt-cli": "0.1.13",
"grunt-contrib-jshint": ">0.8.0",
"grunt-contrib-uglify": ">0.3.2",
"load-grunt-tasks": ">=0.3.0",
"requirejs": ">=2.1.10",
"grunt-exec": "~0.4.5"
}
同样的事情对我的同事来说很好。
答案 0 :(得分:3)
我今天遇到了类似的错误,并通过升级npm修复了它:
npm install -g npm
我有2.14版本,升级后变成了3.8
答案 1 :(得分:2)
你两次声明了grunt依赖。一个用于开发,另一个用于开发。您还有两个不同的版本规则。这就是导致冲突的原因。
您应该删除其中一个。 (通常grunt是devdependencies的一部分)
依赖
"grunt": "~0.4.2",
devDependencies
"grunt": "0.4.2",
编辑:
我测试了它,这解决了问题:
"dependencies": {
"grunt-contrib-requirejs": "~0.4.1",
"grunt-config": "~0.1.4",
"grunt-string-replace": "~0.2.7",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-cssmin": "~0.10.0"
},
"devDependencies": {
"grunt": "~0.4.2",
"grunt-cli": "0.1.13",
"grunt-contrib-jshint": ">0.8.0",
"grunt-contrib-uglify": ">0.3.2",
"load-grunt-tasks": ">=0.3.0",
"requirejs": ">=2.1.10",
"grunt-exec": "~0.4.5"
}
答案 2 :(得分:-1)
更新我的所有全局npm包为我解决了这个问题:
npm update -g