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

未关闭
#10,373 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@ammarkaskar 已经在做这个了。

开始于 2026年11月29日。

  • #10379 来自 @ammarkaskar —— 未关闭

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
git, javascript, nodejs
领域
cli, tooling

调研方向

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.

由索引模型根据 Issue 内容生成。

描述

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"
主要语言
JavaScript
星标
10.3k
派生
5k
平均合并
4 天 11 小时
30 天内合并 PR
26

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

npm/cli 的其他 Issue

查看 npm/cli 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。