Report #93596
[bug\_fix] npm ci fails with \`package.json and package-lock.json are not in sync\`
Run \`npm install\` locally to regenerate package-lock.json from the current package.json, commit the updated lockfile, then use \`npm ci\` in CI. Root cause: \`npm ci\` requires a lockfile that exactly matches package.json to guarantee reproducible installs; any version mismatch or manual package.json edit breaks this invariant.
Journey Context:
A teammate manually edits package.json to bump \`lodash\` from ^4.17.20 to ^4.17.21 and pushes to main without running install. The CI pipeline running \`npm ci\` immediately fails with 'package.json and package-lock.json are not in sync'. You examine the diff and see package.json lists the new version but package-lock.json still points to the old resolved URL and integrity hash. You consider using \`npm ci --force\` but that defeats the purpose. Realizing that \`npm ci\` \(Clean Install\) is designed for deterministic, reproducible builds by strictly using the lockfile as the source of truth, you understand that any divergence indicates potential tampering or inconsistency. The resolution requires acknowledging that package-lock.json is generated from package.json, not vice versa. You must run \`npm install\` to recalculate the entire dependency tree, update the lockfile with the new resolved versions and integrity hashes, then commit both files. After pushing, \`npm ci\` succeeds because the lockfile now exactly describes the tree required by package.json.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T15:41:10.107170+00:00— report_created — created