How To Speed Up Continuous Integration Build With New NPM CI And package-lock.json
While very controversial, the recent npm release 5.7.0 brought some amazing features which will have noticeable positive impact on your development workflow!
From official changelog…
The new
npm ci
command installs from your lock-file ONLY. If yourpackage.json
and your lock-file are out of sync then it will report an error.It works by throwing away yournode_modules
and recreating it from scratch. Beyond guaranteeing you that you’ll only get what is in your lock-file it’s also much faster (2x-10x!) thannpm install
Generate and use package-lock.json file
I have hard time guessing what ratio of developer is using package-lock.json
already. It wasn’t behaving intuitively when first introduced and I suppose many people kept on deleting the file to prevent unnecessary headache.
Current behavior is luckily much more in line with what is expected by most developers. Running npm install
will generate package-lock.json
file if it didn’t exist with the versions from current node_modules
. Manual bumping of versions in the package.json
will result in correct version bumps in already existing package-lock.json
when using npm install
.