[BUG] allow-git=root rejects a root git dependency with EALLOWGIT after its tag or branch changes in package.json

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

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

Từ ngày 29/11/2026.

  • #10379 của @ammarkaskar — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
45/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ệ
git, javascript, nodejs
Lĩnh vực
cli, tooling

Hướng nghiên cứu

Start by reproducing with the steps in the issue: set allow-git=root, install a root git dependency, change its tag, and install again to see EALLOWGIT. Search the codebase for the EALLOWGIT error and the allow-git root check, then find where a changed git ref interacts with the lockfile. Done means the second install succeeds with allow-git=root and a regression test covers changing a root git ref.

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

Mô tả

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

With allow-git=root, changing the tag or branch of a git dependency
that is declared in the root package.json makes npm install fail:

npm error code EALLOWGIT
npm error Fetching non-root packages of type "git" have been disabled
npm error Refusing to fetch "ini@git+ssh://[email protected]/npm/ini.git#180a8d5c72d7f13ed70c53619132f3a8ee5ac6ed"

The package is a direct dependency of the project root. A fresh install
of the same package.json without a lockfile works.

Expected Behavior

npm install re-resolves the changed ref and installs the package,
since it is a root dependency and allow-git=root allows those.

Steps To Reproduce
mkdir repro && cd repro
echo 'allow-git=root' > .npmrc

echo '{"name":"repro","dependencies":{"ini":"github:npm/ini#v5.0.0"}}' > package.json
npm install   # works

echo '{"name":"repro","dependencies":{"ini":"github:npm/ini#v6.0.0"}}' > package.json
npm install   # fails with EALLOWGIT

Workaround: run npm install --allow-git=all once. It updates the
lockfile, after which npm ci and npm install work again with
allow-git=root.

Environment
  • npm: 12.2.3 (also 11.21.3 and 11.20.0)
  • Node.js: v26.13.1
  • OS Name: Ubuntu 26.04.1 LTS
  • System Model Name: n/a
  • npm config:
allow-git = "root"
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.