EUSAGE cicd install_error ai_generated true

npm ERR! code EUSAGE npm ERR! `npm ci` can only install packages when your package-lock.json or npm-shrinkwrap.json is in sync with package.json

ID: cicd/npm-ci-lockfile-outdated

Also available as: JSON · Markdown · 中文
95%Fix Rate
87%Confidence
1Evidence
2023-04-05First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
npm 9.6.0 active
Node.js 18.16.0 active
npm 10.2.0 active

Root Cause

npm ci failed because package-lock.json is out of sync with package.json, often due to manual edits to package.json without running npm install to update the lockfile.

generic

中文

npm ci 失败,因为 package-lock.json 与 package.json 不同步,通常是由于手动编辑 package.json 而未运行 npm install 更新锁文件。

Official Documentation

https://docs.npmjs.com/cli/v9/commands/npm-ci

Workarounds

  1. 95% success Regenerate the lockfile by running: npm install && git add package-lock.json && git commit -m 'Update lockfile'. Then retry npm ci.
    Regenerate the lockfile by running: npm install && git add package-lock.json && git commit -m 'Update lockfile'. Then retry npm ci.
  2. 85% success If the discrepancy is due to version ranges, pin exact versions in package.json to avoid lockfile drift.
    If the discrepancy is due to version ranges, pin exact versions in package.json to avoid lockfile drift.

中文步骤

  1. Regenerate the lockfile by running: npm install && git add package-lock.json && git commit -m 'Update lockfile'. Then retry npm ci.
  2. If the discrepancy is due to version ranges, pin exact versions in package.json to avoid lockfile drift.

Dead Ends

Common approaches that don't work:

  1. 20% fail

    Deleting node_modules and package-lock.json and re-running npm install may break CI reproducibility by generating a different lockfile.

  2. 30% fail

    Running npm audit fix can modify package.json or lockfile, introducing unintended changes.