Skip to content
Latchkey

npm ci vs npm install in CI: Which to Use

In CI you almost always want npm ci, not npm install - here is why.

They look similar but behave differently around the lockfile and reproducibility.

npm installnpm ci
Uses lockfileMay update itInstalls exactly from it
node_modulesReuses/patchesDeletes and reinstalls clean
ReproducibleNoYes
Fails on lockfile driftNoYes (by design)

Use npm ci in CI

npm ci gives clean, reproducible installs and fails loudly if package.json and the lockfile disagree - which is exactly what you want in a pipeline. npm install is for local development where you intend to change dependencies.

The verdict

CI: always npm ci (with the lockfile committed). Local dependency changes: npm install.

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card