简体   繁体   中英

While publishing npm, getting npm publish npm ERR! 403 Forbidden PUT https//registryname/ - forbidden

I am trying to publish the package using npm publish command. but I am getting this error every time.

npm ERR! code E403
npm ERR! 403 Forbidden - PUT https://registryname - forbidden

I have

"publishConfig": {
   "registry": "https://registryname"
}

and in.npmrc

registry=https://registryname

I have tried many solutions but no luck.

Or anyone trying to publish a package (for the first time) and getting the same failure, it could also be because you just created npmjs account, and you haven't yet verified the account creation through a link that was sent to your email address.

npm ERR! 403 403 Forbidden - PUT https://registry.npmjs.org/mac-info-lib - you must verify your email before publishing a new package: https://www.npmjs.com/email-edit

Do you have an account? You can;

  1. First check your account using npm whoami
  2. if you have an account then login, your session might be expired. npm login . Follow the login prompt.
  3. Then once you are logged in, make sure you are in the right directory, you wont be able to publish if you are not in the directory of the project you are working on.

If your library has a name that is already existed in npm registry. It will give you this error.

npm ERR! code E403
npm ERR! 403 Forbidden - PUT https://registryname - forbidden

Solution:

  1. If you are publishing your package first time, you need to make sure the name is unique that is not already there.
  2. If you are publishing or updating new version, then make sure you update the version number in package.json fie.

Be sure to login first to the official link: https://www.npmjs.com/login

then they will ask for mail verification(A kind of pop up at the header).

After verification npm publish will work.

Note: if still not working change package name

Or just go into your package.json and update the version number.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM