The error, verbatim
Jump to the fix ↓npm error code EALLOWGIT
npm error Fetching packages of type "git" have been disabled
npm error Refusing to fetch "is-odd@github:jonschlinkert/is-odd"
The fix that worked
If the git link is in your own package.json, allow it in the project .npmrc:
allow-git=rootNot it? Every cause, tested ↓Tested on
- npm
- 12.2.2 (the current latest), and 11.21.2 for comparison
- Node
- 24.14.0 (npm 12.2.2 warns that it wants 24.15.0 or newer; every case still ran)
- git
- 2.54.0 (Windows)
- OS
- Windows 11 Pro, November 16, 2026; the same cases on Node 26.13.1 on Ubuntu and Windows (GitHub Actions, November 16): same results
Contents
npm 12 sets allow-git to none. A dependency that points at a git repository instead of a version now fails with EALLOWGIT. npm 11.21.2 installed all of them without a word, because its default is all:
> npm config get allow-git
none
That is npm 12.2.2. On 11.21.2 the same command prints all. This post covers the git side only: shorthand, URLs, tags, commit SHAs, npx, npm ci and dependencies of dependencies. Tarball URLs fail with a different code and setting, covered in npm error code EALLOWREMOTE.
Every git case, on both versions
I ran each case in a fresh folder against GitHub, using jonschlinkert/is-odd (and piuccio/cowsay where a command needed a bin). Defaults on both versions.
| Case | npm 11.21.2 | npm 12.2.2 | Setting that fixed it |
|---|---|---|---|
"is-odd": "github:jonschlinkert/is-odd" |
installed | EALLOWGIT |
root |
git+https://github.com/jonschlinkert/is-odd.git |
installed | EALLOWGIT |
root |
a tag, github:jonschlinkert/is-odd#3.0.1 |
installed | EALLOWGIT |
root |
a semver range, #semver:^3 |
installed | EALLOWGIT |
root |
a commit SHA, #75e749a… |
installed | EALLOWGIT |
root |
npm install github:jonschlinkert/is-odd |
installed | EALLOWGIT |
root |
npx github:piuccio/cowsay hi |
ran | EALLOWGIT |
root |
npm ci with a git resolved in the lockfile |
installed | EALLOWGIT |
root |
| a package whose own dependency is a git URL | installed | EALLOWGIT, “non-root” |
all, or an override |
| a git dependency marked optional | installed | skipped, no error | all to get it |
The error text is the same for every EALLOWGIT row apart from the package name after Refusing to fetch. A tag, a range and a SHA all failed the same way, and each installed the version you would expect once allowed: 3.0.1 for the tag and the range, 3.0.0 for the SHA, which is the commit of the 3.0.0 tag.
The transitive row is a constructed case, explained below. The optional row is a real package.
Fix: allow root in the project
Put this in the .npmrc next to package.json and commit it:
allow-git=rootFor a single command, pass it as a flag: npm install --allow-git=root. npx takes the same flag before the package name.
Dependencies of dependencies: “non-root”
root covers git links written in your own package.json. It does not cover a git link inside a package you depend on. For that I built a package, holder, whose package.json depends on github:jonschlinkert/is-odd#3.0.1, packed it with npm pack, and installed the tarball. This is a constructed case, not a package from the registry. With allow-git=root on npm 12.2.2:
npm error code EALLOWGIT
npm error Fetching non-root packages of type "git" have been disabled
npm error Refusing to fetch "is-odd@github:jonschlinkert/is-odd#3.0.1"
With the default none, the same install says Fetching packages of type "git" without the word non-root. So the word tells you the setting is already working for your own dependencies.
The narrower fix is an override that swaps the git link for the same version from the registry. In the root package.json:
"overrides": {
"is-odd": "3.0.1"
}If the package is not on the registry, allow-git=all installed it too. all lets every package in the tree run git against any repository, which is what npm 12 turned off.
I also looked for a real registry package with a git dependency. coffee-script-redux@2.0.0-beta8 lists cscodegen as a git URL, but under optionalDependencies as well. On npm 12.2.2 it installed 17 packages with no error and no cscodegen. With --allow-git=all it installed 18, with cscodegen. On npm 11.21.2 it installed 18. If a package seems to be missing after the upgrade and nothing failed, an optional git dependency is one place to look.
The allow-git values
The npm 12.2.2 docs list three values. The middle column is what the docs say; the last is what I saw.
| Value | What the docs say | What I saw |
|---|---|---|
none (default) |
no git dependency is fetched | every case above failed, direct and transitive |
root |
only git dependencies in your project’s package.json; also allows git for commands like npm view |
direct cases installed; the holder case failed with “non-root” |
all |
any git dependency | direct and transitive cases installed |
npm view github:jonschlinkert/is-odd version failed with EALLOWGIT by default and printed 3.0.1 with --allow-git=root.
A value npm doesn’t know
Anything outside all, none and root prints a warning:
npm warn invalid config allow-git="yes" set in D:\...\.npmrc
npm warn invalid config Must be one of: all, none, root
What happened next depended on where the value came from. In .npmrc (I tried yes, true, false, 1, 0 and an empty value) and in the npm_config_allow_git variable, the direct install went through anyway, and the holder case still failed. As a flag, --allow-git=yes and --allow-git=false stayed blocked. I did not look into why. The practical point: allow-git=true in a file does not mean none, so spell the value out.
Where to set it, and which one wins
allow-git worked from every place I tried: the project .npmrc, the user .npmrc, the global config file, the npm_config_allow_git environment variable and the --allow-git= flag. I set each one to none or all for the same direct install. The winner was always the same, in this order:
- the command-line flag
- the environment variable
- the project
.npmrc - the user
.npmrc - the global config file
For example, a project .npmrc with allow-git=all still failed when npm_config_allow_git=none was set, and a project file with none still installed when --allow-git=all was passed. A user .npmrc with all lost to a project .npmrc with none. npm config get allow-git printed the winning value each time, so check it first when the line seems to be ignored.
If you can’t change the project
This is the case for a CI job or someone else’s repository. Nothing in package.json has to change:
- Set the environment variable for the job:
npm_config_allow_git=root. On npm 12.2.2 it installed even withallow-git=nonein the project.npmrc. - Pass
--allow-git=root(orallfor a git link deeper in the tree) on the command you run. - Put
allow-git=rootin your user.npmrcwithnpm config set allow-git=root. It only applies where the project has noallow-gitline of its own. - Stay on npm 11 for now. Its default is
all, and 11.21.2 installed every case in the table.
Prefer the narrowest value that works. root for your own git links, an override for a transitive one, all last.
How this was tested
Windows 11 Pro, Node 24.14.0, git 2.54.0, on November 16, 2026. npm 12.2.2 and 11.21.2 were installed into their own folder with npm install npm@12.2.2 and run with that Node, with the home folder, user and global config files and the cache all pointed at a scratch folder, so nothing touched a real .npmrc or the global npm. No sign-in or tokens were used. Node 24.14.0 is older than the 24.15.0 that npm 12.2.2 asks for, so npm printed an engine warning on every run; the results above are from those runs and I have not repeated them on a newer Node. Each case ran in a fresh folder. The npm ci lockfile was made by npm 11.21.2 and recorded the dependency as git+ssh://git@github.com/jonschlinkert/is-odd.git#a80ee0d…; npm 12.2.2 refused it by default and installed it with root. The same cases run on GitHub Actions on Ubuntu and Windows with Node 26.13.1 gave the same results; the script is eallowgit/ci.sh in nk-repro.
— N.K., end of entry No.103