NPM Shrinkwrap and TeamCity Build Fails

I’ll start by pointing out that I picked the title that was most similar to the search terms I used when trying to find out what was going on with my builds the other day! I couldn’t find any information to explain what I was seeing so here’s what I figured out…

What did you do!?!

Recently some people at work have been worried about possible inconsistencies in ours builds due to the ability for npm to get more up to date package versions depending on what we’ve added to the packages.json file. This never seemed to be the root cause of problems we’d encountered but if it meant taking it of the table as a possibility, it was going to make my life easier!


It took a little while to get to the root of this problem, but here’s the short answer:

  1. TeamCity had picked up this branch, checked it out, and gone through it’s steps.
  2. We don’t clear out the directory on each checkout as it massively increases our build times.
  3. Not clearing the directory left us with a npm-shrinkwrap.json file. All of the other branches didn’t have this file, so while TeamCity was checking out their packages.json file, it was not touching the shrinkwrapped verson.
  4. When npm install was run as part of the build process on these branches, it was using the other branch’s shrinkwrap file.
  5. FAIL.

Never fear…

This problem will solve itself when all of the other branches get in sync and are using the shrinkwrapped file, however while you’re waiting for this it can cause some confusing moments!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store