NPM 5.7.0 introduced the new npm ci
command. It's a faster, more reliable way of installing dependencies on test environments, continuous integration or during deployment.
npm ci
comes with some benefits over npm install, but also with some pre-requirements:
- 🏎 it's faster - some report a 2–5x speed improvement of their CI
- ☝️ it can only install whole projects, not single dependencies
- 👉 it only considers
package-lock.json
, make sure the file is checked in! - 👌 if
package.json
andpackage-lock.json
do not match, an error occurs - 💪 it never updates
package.json
orpackage-lock.json
- 👍 it throws away existing
node_modules
and starts with a clean slate
Some of these improvements have since found its way to well-known npm install
. The official docs for the npm ci
command can be found here and the introductory blog post from March can be read here.
It's time to update your Dockerfile
, .travis.yml
, and other configurations that can benefit from faster installs.