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!
I ran npm shrinkwrap which, in basic terms, file called npm-shrinkwrap.json and lists out exact versions and locations for your dependencies and their subdependencies. There are pros and cons to this solution, but it was enough to satisfy members of the team that had concerns.
Until TeamCity started failing on every branch…
It took a little while to get to the root of this problem, but here’s the short answer:
- My NPM shrinkwrap change was sitting in a branch waiting for QA to run all their tests against the branch.
- TeamCity had picked up this branch, checked it out, and gone through it’s steps.
- We don’t clear out the directory on each checkout as it massively increases our build times.
- 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.
- When npm install was run as part of the build process on these branches, it was using the other branch’s shrinkwrap file.
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!
Hopefully anyone googling for what is going on I will have saved you a little bit of time.