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 install | npm ci | |
|---|---|---|
| Uses lockfile | May update it | Installs exactly from it |
| node_modules | Reuses/patches | Deletes and reinstalls clean |
| Reproducible | No | Yes |
| Fails on lockfile drift | No | Yes (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.