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

Aperta
#10,373 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@ammarkaskar ci sta già lavorando.

Dal 29/11/2026.

  • #10379 di @ammarkaskar — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
git, javascript, nodejs
Ambito
cli, tooling

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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"
Lingua principale
JavaScript
Stelle
10.3k
Fork
5k
Merge medio
4g 11h
PR unite (30g)
26

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di npm/cli

Tutte le issue di npm/cli

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.