NPM CI: A Command You Should Know

Florian Hämmerle
1 min readMay 26, 2018
Photo by Pankaj Patel on Unsplash

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 and package-lock.json do not match, an error occurs
  • 💪 it never updates package.json or package-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.

--

--

Florian Hämmerle

raised & based in the Alps • co-founded a digital studio • former CPO at a news company • partner at a software consultancy • into products and innovation