[BUG] npm install materializes registry dependency devDependencies from a pnpm tree
维护者通常 2 天内回复
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 20/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- javascript, node.js
调研方向
Start by reading the reproduction steps and the linked pull request #10256, which is already open against this issue. The report identifies a dependency selection problem when npm installs into a pnpm tree, but names no source files or tests to begin from. Done means the fixture no longer materializes the registry dependency’s devDependencies, or npm gives a clear diagnostic, while the npm-managed control still installs both requested packages.
由索引模型根据 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 in an isolated prefix.
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
Adding an unrelated package with npm to a pnpm-installed registry dependency tree materializes that dependency's development-only tools. A one-package starting tree grows by 319 packages, including Mocha and gulp tooling; an npm-managed control for the same root manifest adds only the two requested production packages. This is separate from the TypeError: this fixture exits successfully but builds the wrong dependency set.
Steps To Reproduce
In a new empty directory, using the versions below, run:
printf '{"name":"repro","version":"1.0.0","private":true}
' > package.json
pnpm add --ignore-scripts [email protected]
npm install [email protected] --ignore-scripts --no-audit --no-fund
node -e 'console.log(require("./node_modules/is-number/package.json").devDependencies)'
node -p 'require("./node_modules/mocha/package.json").version'
The starting registry package has no production dependencies. Its development dependencies include benchmarked, chalk, gulp-format-md, and mocha. None is declared in the root manifest. This reproduction does not use a git dependency, local-folder dependency, workspace, build hook, or script execution.
Expected Behavior
Installing a registry dependency for use in a consumer project should not install its test and documentation tools. Install the root manifest's dependencies and their production/peer requirements, or give an actionable diagnostic for an unsupported existing layout.
Actual Behavior
Both tested builds exit 0 with added 319 packages. Mocha is present at node_modules/mocha; the root manifest only declares is-number and picocolors. The dependency's own devDependencies are resolved even though the command does not run from that package's directory.
Evidence
- Expected source: The
devDependenciesdocumentation separates consumer dependencies from the package author's development tools and places development installs at the package root. - Failure source: The executed one-package fixture above, npm's
added 319 packagesoutput, and the presence of Mocha in the resulting consumer tree. - Evidence provenance: observed
- Local verification: reproduced
- Reproduction completeness: complete
Two separate fresh runs with the published CLI and one with current source installed the extra tools. The npm-managed control (npm install [email protected] [email protected] in an empty project) exits 0 with added 2 packages and no Mocha. Adding picocolors using pnpm on the one-package starting tree also exits 0 without installing Mocha. Lifecycle scripts remained disabled throughout, so the observation is dependency materialization rather than a build-script effect. Other tested pnpm trees failed with E404 when development-only package references were unavailable; that is additional impact of this dependency-selection behavior, not a claim that all pnpm trees fail.
Environment
- Platform: Linux x86_64.
- Node.js: 26.13.0.
- Latest published npm: 12.2.2, installed in an isolated prefix.
- Current
latestsource: ab930df82a63796a9390b9766f11e5c4c0fc9e1c, bootstrapped usingnode scripts/resetdeps.js; the same result was observed withnode . install. - pnpm: 12.18.0, installed in an isolated prefix.
- User configuration, cache, and store were isolated; lifecycle scripts and audit were disabled for the reduced tests.
Restoration check
Run the one-package fixture in a fresh directory and verify that the npm command either installs only the intended production/peer graph without Mocha or reports the unsupported existing layout clearly. The clean npm-managed control must still install both requested packages. No dependency's test tooling should be materialized simply because it resides in pnpm's store.
References
- Existing non-npm-tree tracking issue: related interoperability scope; its reported null-target crash and discussion do not describe successful installation of dependency development tools.
- Merged npm-store fix: addressed development edges for npm's own
.storelayout; the current.pnpmfixture still installs the tools. A shared cause is not asserted. - Closed git-dependency report: maintainers explained that git dependencies with build scripts can intentionally install development tools. This fixture uses a registry package and disables lifecycle scripts, so it does not rely on that declined behavior change.
Triage assessment
- Impact level: P2
- Assessment status: supported
- Impact basis: The observed fixture downloads and installs hundreds of unnecessary packages; other tested fixtures cannot complete when a dependency's development-only package reference is unavailable. The behavior is bounded to existing pnpm trees in this investigation.
- Workaround status: available
- Workaround basis: Continuing with pnpm leaves Mocha absent. Recreating the dependency tree using npm installs only the two intended production packages in the tested clean control.
- 主要语言
- JavaScript
- 星标
- 10.3k
- 派生
- 5k
- 平均合并
- 4 天 11 小时
- 30 天内合并 PR
- 26
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 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可能重新可做 关联的 PR 已关闭且未合并。 未关闭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 天内回复