`npm update react --package-lock-only` fails with ERESOLVE where `npm update --package-lock-only` succeeds

Đang mở
#10,257 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

@Doomguy-BFG9000 đang làm issue này rồi.

Từ ngày 8/11/2026.

  • #10262 của @Doomguy-BFG9000 — đ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
53/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, node.js
Lĩnh vực
cli, devtools

Hướng nghiên cứu

Start by reproducing the failure in npm 11.19.0 with the supplied repository commit and compare the named-package update with the bare update. Trace how npm resolves peer dependencies when package names are supplied to npm update --package-lock-only, then identify the relevant tests and add coverage for this lockfile-only case. Done means naming react succeeds and preserves the root pin at 18.3.1.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

area:peer-dependencies Bug cmd:update Priority 2

Environment

  • npm 11.19.0, node v24.21.0, Linux x86_64

Steps to reproduce

Public repo storytold/artcraft at 1f969a9224934a55417daf10359a6fb1458b63f4, directory frontend/. The root package.json pins "react": "18.3.1" exactly. The workspace apps/artcraft depends on "react": "^18.2.0" and "@preact/signals-react": "^2.0.1", whose peer range is react@"^16.14.0 || 17.x || 18.x || 19.x".

git clone https://github.com/storytold/artcraft && cd artcraft/frontend
git checkout 1f969a9224934a55417daf10359a6fb1458b63f4

npm update --package-lock-only --ignore-scripts         # exit 0
git checkout -- package-lock.json
npm update react --package-lock-only --ignore-scripts   # exit 1, ERESOLVE

Expected

Naming react updates no more than a plain npm update does. The project's own react requirements are 18.3.1 (root) and ^18.2.0 (workspace), so the result should keep react 18.3.1, as plain npm update does without error.

Actual

npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error While resolving: @preact/[email protected]
npm error Found: [email protected]
npm error   react@"18.3.1" from the root project
...
npm error Conflicting peer dependency: [email protected]
npm error   peer react@"^16.14.0 || 17.x || 18.x || 19.x" from @preact/[email protected]
npm error   apps/artcraft/node_modules/@preact/signals-react

With react named, npm appears to choose [email protected] (the latest the peer range allows) for the peer edge, then rejects it against the root's exact pin. Naming react-dom or @preact/signals-react alone succeeds.

Context

We name every declared registry package (npm update a b c ...) instead of running a bare npm update so that Git dependencies stay at their locked commits. That makes the named form the only one available to us when a lock has Git dependencies.


Found by an automated test of a dependency-update tool across public repositories.

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.