[BUG] `npm ci` rejects patched dependencies when the patch file is checked out with CRLF line endings (Git for Windows default)
メンテナーはふだん 2 日以内に返信
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 25/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- javascript, nodejs
調査の方向性
Start by reproducing with npm patch commit and npm ci on a patch file converted to CRLF, as the steps describe. The integrity check that compares the patch against patched.integrity in the lockfile is where the mismatch comes from. Linked PR #10353 is already open against this issue, so check it before starting. Done means npm ci accepts a CRLF-checked-out patch whose content matches the LF original.
索引モデルが issue の本文から書いたものです。
説明
Is there an existing issue for this?
- I have searched the existing issues
This issue exists in the latest npm version
- I am using the latest npm
This is not just a request to bump a dependency for a CVE
- This is not solely a request to bump a dependency for a CVE
Current Behavior
npm patch commit writes patches/<pkg>@<version>.patch with LF line endings, and the lockfile records patched.integrity as a sha512 of the file's raw bytes.
Git for Windows sets core.autocrlf=true in its system gitconfig by default. When a teammate on Windows clones the repo, git checks the patch file out with CRLF line endings, so its hash no longer matches the lockfile and npm ci fails:
npm error `npm ci` can only install packages when your package.json and package-lock.json are in sync. Please update your lock file with `npm install` before continuing.
npm error Invalid: patch for [email protected] does not match the patch recorded in the lock file
npm install instead rewrites patched.integrity, so the lockfile keeps changing back and forth between Windows and macOS/Linux contributors.
The patch still applies correctly with CRLF line endings. Only the integrity check fails.
Expected Behavior
A patch file that differs only by git's line-ending conversion should match the recorded integrity, so npm ci installs the patched dependency.
Steps To Reproduce
- On macOS/Linux (or Windows with
core.autocrlf=false):npm install <pkg>, thennpm patch add <pkg>, edit a file, runnpm patch commit <dir>, and commitpackage.json,package-lock.jsonandpatches/. - On Windows with a default Git for Windows install (
git config core.autocrlfprintstrue): clone the repo. - Run
npm ci. It fails with the error above.
Shortcut without a second machine: after step 1, convert the patch file to CRLF, then run npm ci:
node -e "f='patches/<pkg>@<ver>.patch';fs.writeFileSync(f,fs.readFileSync(f,'utf8').replace(/\n/g,'\r\n'))"
npm ci
Environment
- npm: 12.2.3 (
latestbranch) - Node.js: 24.20.0
- OS Name: Windows 11
- git: Git for Windows, default
core.autocrlf=true
- 主要言語
- JavaScript
- スター
- 10.3k
- フォーク
- 5k
- 平均マージ
- 4日 11時間
- マージ済み PR(30日)
- 26
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
npm/cli のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 2 日以内に返信
-
[BUG] scripts/dependency-graph.js splits npm-cli-repos.txt on os.EOL, so DEPENDENCIES.md depends on the checkout's line endings対応中かも @saruk-vedant が 7 日前に担当しました。 オープンBug Needs Triage Triage Requested
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 2 日以内に返信
-
[BUG] npm pkg delete removes the first array item for a nonexistent property対応中かも @drawliin が 42 日前に担当しました。 オープンcmd:delete Priority 3
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
メンテナーはふだん 2 日以内に返信
-
create node pr: Node.js 20 deprecation & `DEP0040` warnings logged再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンEngineering Priority 1
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
メンテナーはふだん 2 日以内に返信
-
`npm audit signatures` does not report how many packages it skipped for want of registry keys対応中かも @greenlincoln05 が 63 日前に担当しました。 オープンPriority 3
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 2 日以内に返信
似ている issue
-
documentation
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
githubnext/gh-aw-workshop#6332 ·
メンテナーはふだん 1 日以内に返信
-
App Designer bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
avniproject/avni-webapp#1858 ·
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 96/100
hiero-ledger/hiero-sdk-js#4834 ·
メンテナーはふだん 1 日以内に返信
-
[组件名称] 描述问题的标题オープン🐞 bug 🧐 unconfirmed
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Tencent/tdesign-miniprogram#4744 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Y-axis tooltip hides near the bottom of the plot while the y crosshair stays visible対応中かも @lazerg が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
apexcharts/apexcharts.js#5449 ·
メンテナーはふだん 3 日以内に返信