[BUG] npm install materializes registry dependency devDependencies from a pnpm tree
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 20/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript, node.js
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- JavaScript
- Star
- 10.3k
- Fork
- 5k
- Merge trung bình
- 4 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 26
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của npm/cli
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 2 ngày
-
[BUG] scripts/dependency-graph.js splits npm-cli-repos.txt on os.EOL, so DEPENDENCIES.md depends on the checkout's line endingsCó thể đã có người làm @saruk-vedant đã nhận 7 ngày trước. Đang mởBug Needs Triage Triage Requested
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 2 ngày
-
[BUG] npm pkg delete removes the first array item for a nonexistent propertyCó thể đã có người làm @drawliin đã nhận 42 ngày trước. Đang mởcmd:delete Priority 3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 2 ngày
-
create node pr: Node.js 20 deprecation & `DEP0040` warnings loggedCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởEngineering Priority 1
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 80/100
Maintainer thường phản hồi trong vòng 2 ngày
-
`npm audit signatures` does not report how many packages it skipped for want of registry keysCó thể đã có người làm @greenlincoln05 đã nhận 63 ngày trước. Đang mởPriority 3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 2 ngày
Issue tương tự
-
docs: add SECURITY.md vulnerability reporting policyCó thể đã có người làm @AK-Lmn đã nhận hôm nay. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 72/100
flisk-sh/linux2wasm#12 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
possible bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Mintplex-Labs/anything-llm#7388 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 60/100
Maintainer thường phản hồi trong vòng 1 ngày
-
v6: Minified bootstrap.min.css is missing header infoCó thể đã có người làm @lazerg đã nhận hôm nay. Đang mởbug build confirmed has-pr v6
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
githubnext/gh-aw-workshop#6332 ·
Maintainer thường phản hồi trong vòng 1 ngày