2

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.

Yves M.
  • 29,855
  • 23
  • 108
  • 144
V K
  • 87
  • 4
  • 13

5 Answers5

19

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
mykey
  • 1,943
  • 19
  • 13
5

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.
Simo Mafuxwana
  • 3,702
  • 6
  • 41
  • 59
2

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.
Johar Zaman
  • 1,955
  • 17
  • 27
1

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

  • Login in the web will not impact the "npm" command line. – roychri May 11 '21 at 13:38
  • I am talking about initial Login or Verification of mail. While I was trying to login through cmd it was working but npm publish was not working. So I visited official page and then logged in and verified. After that npm publish started working, could be one solution this way also – sanjeet kumar May 12 '21 at 07:16
0

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

Alex Cory
  • 10,635
  • 10
  • 52
  • 62