CI/CD error

npm ERR! `npm ci` can only install packages when your package.json and package-lock.json are in sync.

npm ci installs exactly what the lockfile says and refuses to guess. It stops when package.json lists something the lockfile doesn't match.

Published

Why this happens

How to fix it

  1. Run `npm install` locally, commit the updated package-lock.json, and push
  2. Pin the same Node and npm versions locally and in CI (the `engines` field, `.nvmrc`, and `actions/setup-node`)
  3. After a lockfile merge conflict, resolve package.json first, then regenerate the lockfile with `npm install` instead of editing it by hand
  4. Don't switch CI to `npm install` to get past it. That hides the drift and makes CI installs non-reproducible