[BUG] npm install materializes registry dependency devDependencies from a pnpm tree

Đang mở
#10,255 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@harshitdeora đang làm issue này rồi.

Từ ngày 7/11/2026.

  • #10256 của @harshitdeora — đang mở

Đá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
Lĩnh vực
backend, cli

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ả

cmd:install Priority 3
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 devDependencies documentation 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 packages output, 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 latest source: ab930df82a63796a9390b9766f11e5c4c0fc9e1c, bootstrapped using node scripts/resetdeps.js; the same result was observed with node . 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 .store layout; the current .pnpm fixture 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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của npm/cli

Tất cả issue của npm/cli

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.