读取peerinvalid输出

时间:2016-04-26 12:21:51

标签: npm npm-install

从香草npm install获取以下输出:

npm ERR! peerinvalid The package grunt does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer grunt-tslint@2.5.0 wants grunt@~0.4.5
npm ERR! peerinvalid Peer grunt-processhtml@0.3.13 wants grunt@>=0.4.x
npm ERR! peerinvalid Peer grunt-contrib-copy@0.8.2 wants grunt@>=0.4.0
npm ERR! peerinvalid Peer grunt-bower-install@1.6.0 wants grunt@~0.4.0
npm ERR! peerinvalid Peer grunt-contrib-connect@0.11.2 wants grunt@>=0.4.0
npm ERR! peerinvalid Peer grunt-contrib-watch@0.4.0 wants grunt@~0.4.0
npm ERR! peerinvalid Peer grunt-lesslint@1.4.1 wants grunt@~0.4.5
npm ERR! peerinvalid Peer grunt-typescript@0.8.0 wants grunt@~0.4.5
npm ERR! peerinvalid Peer grunt-bower-concat@0.6.0 wants grunt@~0.4.0

如何从package.json诊断依赖版本问题,该问题具有以下依赖关系:

"grunt": "0.4.5",
"grunt-bower-concat": "^0.6.0",
"grunt-bower-install": "^1.6.0",
"grunt-bower-task": "^0.4.0",
"grunt-contrib-connect": "0.11.2",
"grunt-contrib-copy": "^0.8.2",
"grunt-contrib-less": "^1.0.1",
"grunt-contrib-watch": "0.4.0",
"grunt-processhtml": "^0.3.8",
"grunt-lesslint": "^1.4.0",
"grunt-tslint": "^2.4.0",
"grunt-typescript": "^0.8.0",
"matchdep": "~0.1.1",
"tslint": "^2.4.2"

peerDependencies具有以下不同的规则:

~0.4.5   :: True, grunt dependency is hard-coded as exactly 0.4.5
>=0.4.x  :: True, 0.4.5 >= 0.4.x
>=0.4.0  :: True, 0.4.5 >= 0.4.0
~0.4.0   :: True, 0.4.5 is a patch of 0.4.0

所有这些都传递了grunt依赖项的声明版本。 NPM为什么还要抱怨?

1 个答案:

答案 0 :(得分:1)

执行npm install时,它会评估当前安装的软件包的兼容性

从空白node_modules目录开始,具有上述依赖关系的package.json将成功安装。

此问题的根本原因是手动安装更高版本的grunt:

# First NPM install, works sucecssfully
npm install

# Upgrade to later version of grunt, note we're not adding --save
npm install grunt@1.0.0

# NPM install now fails with incompatibility error
npm install 

在这种情况下,package.json文件仍显示版本0.4.5的grunt,但已安装的模块仍为1.0.0

要查找已安装模块的列表,请咨询npm list