peerinvalid The package history does not satisfy its siblings’ peerDependencies requirements!

NPM

Okay, this was a real head-scratcher and even when I figured out the cause, I didn’t fully understand it but the problem was solved so I wanted to try to help someone else. So I got this error when I checked in my package.json which kicked off a new build in jenkins. The change I made to my package.json (which was not the direct cause of the error) was to update my version of react to 0.14.7. I also updated redux and react-router. So when I get the following error, I was very confused:

npm ERR! peerinvalid The package react does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer react-disqus-thread@0.2.2 wants react@^0.13.3
npm ERR! peerinvalid Peer react-dom@0.14.7 wants react@^0.14.7
npm ERR! peerinvalid Peer react-redux@4.4.0 wants react@^0.14.0

So I didn’t understand what could be causing the problem since react was updated to 0.14.7 which should meet all the¬†peerDependencies. And of course, when I run npm install after deleting my node_modules folder, everything works fine. I was stumped. So the first thing I realize after looking through the stacktrace is that jenkins is running npm v2 and I have npm v3 locally. So I at least understood why things were working locally, but I couldn’t¬†easily resolve it since I wasn’t going to ask devops to upgrade npm just to get this fixed (we have plans to upgrade node and npm). So the real fix is still out there. Next I look at react-dom and react-redux to figure out why their dependencies are failing. I’ll skip to the end and say that the problem wasn’t due to react-dom and react-redux. Luckily someone pointed me in the right direction (okay, I’ll be honest, they figured out the solution and told me). Drum roll please… react-disqus-thread was a super old package that was used and because it depended on react 0.13.3 and because we were using npm v2 – it raised an error because it installed react 0.13.3 and threw an error because there were conflicting versions of react. So, to solve the original problem and get jenkins to build my app, I updated react-disqus-thread and my build was working again. So there you have it folks, upgrade to npm v3 or you could deal with fun issues like this.