[BUG] scripts/dependency-graph.js splits npm-cli-repos.txt on os.EOL, so DEPENDENCIES.md depends on the checkout's line endings

未关闭 适合新手
#10,316 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@saruk-vedant 已经在做这个了。

开始于 2026年11月23日。

  • #10317 来自 @clddup —— 已关闭,未合并
  • #10337 来自 @saruk-vedant —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃

调研方向

从 scripts/dependency-graph.js 开始,查看其中如何使用 os.EOL 拆分 scripts/npm-cli-repos.txt,并阅读 scripts/resetdeps.js 生成依赖文件的方式。分别使用 LF 和 CRLF 输入重现,然后检查两次运行后 DEPENDENCIES.md 和 DEPENDENCIES.json 是否都与已提交的文件一致。

由索引模型根据 Issue 内容生成。

描述

Bug Needs Triage Triage Requested
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

On Windows, in a clone whose scripts/npm-cli-repos.txt has LF endings, node ./scripts/resetdeps.js leaves DEPENDENCIES.md and DEPENDENCIES.json modified: 139 lines are removed from DEPENDENCIES.md, among them edges between npm's own packages such as bin-links-->cmd-shim and cacache-->ssri. On Linux the same happens with the file in CRLF.

The file is split on os.EOL: https://github.com/npm/cli/blob/787f1520fa412e91a5792468f1c7f25b166867a6/scripts/dependency-graph.js#L12

Expected Behavior

DEPENDENCIES.md and DEPENDENCIES.json come out as committed whichever line endings scripts/npm-cli-repos.txt has, as they already do when its endings match os.EOL.

Steps To Reproduce

Steps to reproduce, on Windows:

  1. Clone npm/cli with LF line endings: git clone --branch latest -c core.autocrlf=input https://github.com/npm/cli.git, then cd cli.
  2. node ./scripts/resetdeps.js
  3. git diff --stat

Actual result: step 3 lists DEPENDENCIES.md and DEPENDENCIES.json as modified.

Expected result: step 3 lists nothing.

Reproducer: https://gist.github.com/YevheniiKotyrlo/0ac725143c5278c8c30925c41986905b — bash repro.sh (Git Bash on Windows, or Linux) clones latest, runs node ./scripts/resetdeps.js, then node . run dependencies with scripts/npm-cli-repos.txt written in LF and in CRLF, and compares both files with the committed ones, line endings aside. It exits 1 while the two runs give different files, 0 once both match the committed ones.

Its output on Windows 11:

$ git clone --depth 1 --branch latest https://github.com/npm/cli.git
npm/cli 787f152 (npm 12.2.3), node v26.12.1, win32 10.0.26300, os.EOL "\r\n"
$ node ./scripts/resetdeps.js
$ node . run dependencies --ignore-scripts   # scripts/npm-cli-repos.txt in LF
  DEPENDENCIES.md: 139 lines removed, 6 added
  DEPENDENCIES.json: 52 lines removed, 12 added
$ node . run dependencies --ignore-scripts   # scripts/npm-cli-repos.txt in CRLF
  DEPENDENCIES.md: as committed
  DEPENDENCIES.json: as committed
edges missing from DEPENDENCIES.md with LF, among them:
<   bin-links-->cmd-shim;
<   cacache-->ssri;
RESULT: DEPENDENCIES.md DEPENDENCIES.json differ between scripts/npm-cli-repos.txt in LF and in CRLF

On Linux (Docker node:26):

$ git clone --depth 1 --branch latest https://github.com/npm/cli.git
npm/cli 787f152 (npm 12.2.3), node v26.13.1, linux 6.18.58.1-microsoft-standard-WSL2, os.EOL "\n"
$ node ./scripts/resetdeps.js
$ node . run dependencies --ignore-scripts   # scripts/npm-cli-repos.txt in LF
  DEPENDENCIES.md: as committed
  DEPENDENCIES.json: as committed
$ node . run dependencies --ignore-scripts   # scripts/npm-cli-repos.txt in CRLF
  DEPENDENCIES.md: 139 lines removed, 6 added
  DEPENDENCIES.json: 52 lines removed, 12 added
edges missing from DEPENDENCIES.md with CRLF, among them:
<   bin-links-->cmd-shim;
<   cacache-->ssri;
RESULT: DEPENDENCIES.md DEPENDENCIES.json differ between scripts/npm-cli-repos.txt in LF and in CRLF
Environment
  • npm: 12.2.3 (npm/cli latest at 787f152)
  • Node.js: v26.12.1
  • OS Name: Windows 11 Pro (win32 10.0.26300)
  • System Model Name: custom-built x64 desktop
  • npm config:
; "project" config from <clone>/.npmrc

package-lock = true

; "env" config from environment

cache = "<npm cache folder>"
userconfig = "<an empty file>"

; node version = v26.12.1
; npm version = 12.2.3
主要语言
JavaScript
星标
10.3k
派生
5k
平均合并
4 天 11 小时
30 天内合并 PR
26

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

npm/cli 的其他 Issue

查看 npm/cli 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。