[BUG] aliases don't work with scoped packages in private registries
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
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
Current Behavior
Related to #2884 :
Unfortunately I don't remember what workaround I used last time, but it appears I've run into the same issue, both on NPM 8.19 and NPM 9.4.
in package.json, I have:
"dependencies": {
"aliased": "npm:@scope/my-package@^1.0.1"
}
and when I run npm i, I still am getting a 404
npm ERR! code E404
npm ERR! 404 Not Found - GET https://my.scope.registry.io/@scope/my-package 1.0.1.tgz
npm ERR! 404
npm ERR! 404 'aliased@https://my.scope.registry.io/@scope/my-package-1.0.1.tgz' is not in this registry.
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
strangely enough, if I remove the aliased reference in the package.json it installs with no issue. Then, if I then put the alias back into the package.json, there no longer is an error when I run npm install (or npm ci)
Expected Behavior
npm install can resolve the alias and the scope in the private registry
Steps To Reproduce
.npmrc:
@scope:registry=https://my.scope.registry.io/
//my.scope.registry.io/:_authToken=<token>
rm -r node_modules
npm i
Environment
- npm: 9.4.0
- Node.js: 18.12.1
- OS Name: MacOS 12.6
- System Model Name: Macbook Pro
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure using the package.json dependency alias and the .npmrc scope registry settings, then compare npm i and npm ci after removing and restoring node_modules. Trace the npm CLI's handling of scoped aliases and private registry resolution; done means npm install resolves the alias without a 404 in the stated setup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100