NPM: 403 forbidden - PUT http://registry.npmjs.org/[package-name] - Forbidden
Asked Answered
F

8

14

I am trying to create npm vue component library. I have been working through all the steps but stuck at npm publish.

Please see the below error screenshot for which I am unable to find a solution on google after trying more than an hour(The error message is not that accurate IMHO or maybe I am not able to catch it).

enter image description here

For reference package.json

{
  "name": "@satyam/vue-components",
  "version": "0.1.0",
  "main": "./dist/satyam.common.js",
  "files": [
    "dist"
  ],
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "build-library": "vue-cli-service build --target lib --name satyam ./src/components/index.js",
    "test:unit": "vue-cli-service test:unit",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "core-js": "^3.6.4",
    "vue": "^2.6.11"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "~4.3.0",
    "@vue/cli-plugin-eslint": "~4.3.0",
    "@vue/cli-plugin-unit-jest": "~4.3.0",
    "@vue/cli-service": "~4.3.0",
    "@vue/eslint-config-standard": "^5.1.2",
    "@vue/test-utils": "1.0.0-beta.31",
    "babel-eslint": "^10.1.0",
    "eslint": "^6.7.2",
    "eslint-plugin-import": "^2.20.2",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-promise": "^4.2.1",
    "eslint-plugin-standard": "^4.0.0",
    "eslint-plugin-vue": "^6.2.2",
    "node-sass": "^4.12.0",
    "sass-loader": "^8.0.2",
    "vue-template-compiler": "^2.6.11"
  }
}

After running npm audit

enter image description here

Any help will be appreciated :)

Featly answered 4/5, 2020 at 11:56 Comment(0)
F
25

Update: New user needs to confirm their account first

So after quite a few research and digging around, I found the real issue here.

It's probably documented somewhere very deep or in a light font, but I totally missed to find it.

Your package name should follow your npm username.

In my package.json name property is @satyam/vue-components where it should be @satyamninja/vue-components and that's it. I successfully published the package.

Featly answered 6/5, 2020 at 7:42 Comment(1)
For future folks. The 403 forbidden was possibly because the ORG Scope for @satyam was already taken. To make this clear, the npm username is not required to follow your package scope.Fumikofumitory
C
22

If you are a new user, please confirm your account first!

Cadmus answered 1/1, 2021 at 13:47 Comment(3)
Thanks, this fixed my issue straight away. So simpleHoratius
I'm glad, I could help!Cadmus
thanks... saved me some heartache. why doesn't npm tell you to confirm your account. the reason you are probably creating an account is to try and publish something.Spraggins
G
9

This post has helped me moving past the 403 error, however, after confirming my account over the email link they send and after login into NPM I tried one more time, then I got the following error:

402 Payment Required - PUT https://registry.npmjs.org/@jcarbajal79%2fsimplelib3 - You must sign up for private packages.

If you have the same problem is because the library is being published as private, I checked my package.json and test the following:

No property: "private":"...". - does not work Property set "private":"true" - does not work Property set "private":"false" - does not work

Turns out you have to publish it as public from the command line:

%> npm publish --access=public. - Works!.

Gustafson answered 27/1, 2021 at 22:47 Comment(1)
Thanks a lot, this did it for me too!Steinke
V
4

It sound like you are a new user. You need to confirm your account. Should have get email confirmation from npm site.

Vallecula answered 23/3, 2021 at 14:22 Comment(0)
A
3

I got this error once and I figured out how to fix it after some search. you are getting the 403 forbidden error because there is possibly another package published on NPM with the same name as the one you are trying to publish, you will have to change that to another name. to do so, you can go to your package.json and edit the name of the package.

Angus answered 23/11, 2020 at 12:2 Comment(0)
M
1

If the answers mentioned above not working for anyone then you need to check if your email is verified with the npm account or not, If it's not verified just do the verification and you will be able to publish without any issues.

Manufacture answered 17/1, 2021 at 20:37 Comment(0)
S
1

This also happens because the name you gave the component in the name attribute found in package.json already exists in npm, I recommend giving the component a different name that doesn't exist.

Stairway answered 15/7, 2022 at 15:39 Comment(0)
G
0

I had the same error and was able to resolve by logging into npmjs.com from the command line i.e.

npm login
Username: *******
Password:
Email: (this IS public) *******@***.***
npm notice Please check your email for a one-time password (OTP)
Enter one-time password: 49720564
Logged in as ******* on https://registry.npmjs.org/.

Running npm publish then succeeded and I could see my package in my account.

Goutweed answered 9/1, 2023 at 16:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.