-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
You can download the original TGZ format of a package using npm pack some-package
. You can then re-publish this to a different registry using npm publish some-package*.tgz --registry=https://path/to/my/registry
.
This works great for almost every public package, but there are a few that specify a registry with publishConfig.registry
in their package.json
. The problem is that npm publish
peeks inside the tarball it's publishing to compute the final config used before uploading. I found this ancient, unresolved issue -- auto-closed while tagged "patch-welcome" -- about allowing the --registry
command line option to overrule publishConfig.registry
. As far as I can tell, nothing was ever done about it, so there seems to be no way to override this value without editing the TGZ, but that will change its integrity
.
Expected Behavior
It should be possible to publish a TGZ package to any registry using some version of npm publish
. The simplest solution is probably to fix precedence for --registry
but any other workaround would also be acceptable.
Steps To Reproduce
npm pack yargs
, thennpm publish yargs*.tgz --registry=https://path/to/my/other/registry
npm pack zone.js
, thennpm publish zone.js*.tgz --registry=https://path/to/my/other/registry
The first commands should succeed while the second one fails with the error
npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in to https://wombat-dressing-room.appspot.com
npm ERR! need auth You need to authorize this machine using `npm adduser`
due to the custom registry here.
Environment
- npm: 9.6.2
- Node.js: 18.16.0
- OS Name: Windows 11