How to Fix NPM Package Does Not Satisfy Its Siblings' peerDependencies Requirements

This error is strange, because it appears when you're trying to install a new package globally with NPM, npm install -g <package-name>. The output of this command is something like this:

npm ERR! peerinvalid The package grunt does not satisfy its siblings' peerDependencies requirements!  
npm ERR! peerinvalid Peer grunt-contrib-copy@0.5.0 wants grunt@~0.4.0  
npm ERR! peerinvalid Peer grunt-contrib-clean@0.5.0 wants grunt@~0.4.0  
npm ERR! peerinvalid Peer grunt-contrib-concat@0.3.0 wants grunt@~0.4.0  
npm ERR! peerinvalid Peer grunt-contrib-jst@0.6.0 wants grunt@~0.4.0  
npm ERR! peerinvalid Peer grunt-contrib-watch@0.5.3 wants grunt@~0.4.0  
npm ERR! peerinvalid Peer grunt-contrib-uglify@0.4.1 wants grunt@~0.4.0  
npm ERR! peerinvalid Peer grunt-contrib-cssmin@0.9.0 wants grunt@~0.4.1  
npm ERR! peerinvalid Peer grunt-contrib-less@0.11.1 wants grunt@^0.4.0  
npm ERR! peerinvalid Peer grunt-contrib-coffee@0.10.1 wants grunt@~0.4.0  

The Problem

NPM has the option to define peerDependencies in the package.json file. The peerDependencies are defined like dependencies by package name and respective version. The problem in this specify case: here was a different definition for already installed generator-pho and yeoman-generator packages and the new package I wanted to install kss.

How to Fix It

The error messages don't have to be related to the package you're trying to install. That means, if you want to install e.g. kss the error doesn't mean there is a problem with kss.

Ok, so what? Check the additional messages prompted during the installation attempt and find the packages that cause the problem. The sections look like

…
Binary is fine; exiting  
/usr/local/bin/kss-node -> /usr/local/lib/node_modules/kss/bin/kss-node
npm WARN unmet dependency /usr/local/lib/node_modules/generator-pho/node_modules/yeoman-generator/node_modules/download/node_modules/decompress/node_modules/extname requires map-key@'^0.1.1' but will load  
npm WARN unmet dependency /usr/local/lib/node_modules/generator-pho/node_modules/yeoman-generator/node_modules/download/node_modules/decompress/node_modules/map-key,  
npm WARN unmet dependency which is version 0.1.4  
npm WARN unmet dependency /usr/local/lib/node_modules/yo/node_modules/yeoman-generator/node_modules/download/node_modules/decompress/node_modules/extname requires map-key@'^0.1.1' but will load  
npm WARN unmet dependency /usr/local/lib/node_modules/yo/node_modules/yeoman-generator/node_modules/download/node_modules/decompress/node_modules/map-key,  
npm WARN unmet dependency which is version 0.1.4  
npm ERR! peerinvalid The package grunt does not satisfy its siblings' peerDependencies requirements!  
npm ERR! peerinvalid Peer grunt-contrib-copy@0.5.0 wants grunt@~0.4.0  
npm ERR! peerinvalid Peer grunt-contrib-clean@0.5.0 wants grunt@~0.4.0  
npm ERR! peerinvalid Peer grunt-contrib-concat@0.3.0 wants grunt@~0.4.0  
…

Check out the lines indicated by WARN. The specific messages show the modules which cause the errors. In the output above it's generator-pho and yo.

The solution is to either update or uninstall the modules. Afterwards, you can run the install command for the actual package again and it should complete without errors. Remember: this error is caused by globally installed node modules which should be updated or uninstalled to fix the problem.

Explore the Library

Find interesting tutorials and solutions for your problems.