EUSAGE cicd install_error ai_generated true

npm 错误!代码 EUSAGE npm 错误!`npm ci` 只能在 package-lock.json 或 npm-shrinkwrap.json 与 package.json 同步时安装包

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

其他格式: JSON · Markdown 中文 · English
95%修复率
87%置信度
1证据数
2023-04-05首次发现

版本兼容性

版本状态引入弃用备注
npm 9.6.0 active
Node.js 18.16.0 active
npm 10.2.0 active

根因分析

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

English

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

官方文档

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

解决方案

  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.

无效尝试

常见但无效的做法:

  1. 20% 失败

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

  2. 30% 失败

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