I am unable to publish my package to npm. I am logged in as a user with correct access to that package.
After logging in, I run this command to show I am logged in:
$ npm whoami
ganchrowsci
Then I run this command to ensure that the current user has access to the current package:
$ npm access ls-collaborators
{
"ganchrowsci": "read-write"
}
And then I run publish and it ends with an error:
$ npm publish
...<snip>
npm ERR! code E401
npm ERR! 401 Unauthorized - PUT http://registry.npmjs.com/gs-utils - You must be logged in to publish packages.
This is clearly showing that I am not logged in, but that is also clearly not true. I can't understand why I'm not able to publish. Can you explain what I am doing wrong?
Another piece of information is that, this used to work and we have published many versions of this package, but we haven't published recently. It's only this latest change that we're having trouble with.
If you get E401 with a private npm registry after upgrading to npm v7, remove your package-lock.json and reinstall. The registry url setting in .npmrc needs to match the http/https protocol in your package-lock.json exactly. Use command better-vsts-npm-auth and it should work.
For scoped packages (@angular/router), npm install uses an encoded slash for the “/” between the scope and the package name. This will be displayed as %2f in your Artifactory request logs: There are two (2) locations where the encoded slash may fail.
To publish npm packages to Artifactory, you'll need to configure your package.json to point to your Artifactory npm repository: After doing so, you can run npm publish to deploy a .tar.gz file to the local repository: A common setting for npm is the Enable Dependency Rewrite option for virtual repositories.
The NPM client requests metadata on the package: 2. The metadata contains the download link for the tar.gz file: The metadata is pulled from a “ package.json ” file found in each NPM .tgz file: […] For scoped packages (@angular/router), npm install uses an encoded slash for the “/” between the scope and the package name.
I created an account in npm (https://www.npmjs.com/). Then created a token in that account.
The following command worked for me:
npm adduser --registry=https://registry.npmjs.org/:_authToken=<token-from-npm>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With