My node_modules are in git again

Update (2018)

why cb() was never called when phantom.js is compiled? Why does it happen once in 5 times on a CI server?

There are a few common practices to make your builds reproducible and (more) reliable that the community uses:

Committing node_modules folder to your source code repository

Using npm shrinkwrap

Optional dependency fs-events does not get installed on linux but gets installed on mac. Make sure you generate CI-compatible npm-shrinkwrap.json

Retaining node_modules between CI builds

What I ended up with

sudo npm install -g npm-git-lock  
cd [your work directory]
npm-git-lock --repo [git@bitbucket.org:your/dedicated/node_modules/git/repository.git]

How it works

Amazing features

A fresh npm install for package.json that script sees for the first time, takes 1 min 8 secs
A build with cached node_modules with a package.json that was built before, takes 6 seconds
A build with cached node_modules pointing to same sha1 of current package.json jsut takes 3 seconds