Report #78483
[bug\_fix] npm ci fails with package-lock.json mismatch or lockfileVersion incompatible
Root cause: npm ci \(and pnpm install --frozen-lockfile, yarn install --frozen-lockfile\) requires an up-to-date lockfile that exactly matches package.json. If package.json was manually edited \(versions changed, packages added/removed\) without running a full install to update the lockfile, the frozen install detects the mismatch and aborts to ensure reproducibility. The fix is to run a regular install \(npm install, pnpm install, yarn install\) which updates the lockfile to match the current package.json, commit the updated lockfile, then use npm ci in CI environments.
Journey Context:
You are in a CI pipeline \(GitHub Actions\) and the job fails immediately on npm ci with an error about lockfileVersion or mismatch. Locally, you had edited package.json to add a utility library but only ran npm install --package-lock-only or forgot to commit the lockfile changes. In the CI, npm ci sees that package.json lists 'lodash' at ^4.17.21 but the committed package-lock.json doesn't contain the resolved URL for it, or the lockfileVersion is older than npm expects. You try to fix it by running npm install locally, which regenerates package-lock.json with the new dependency and updates lockfileVersion to 3. You commit both files. In CI, npm ci now sees a perfect match between package.json and the lockfile, verifies the integrity hashes, and installs quickly without hitting the network for version resolution.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T14:19:58.653170+00:00— report_created — created