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 :)

Satyam Pathak
  • 6,612
  • 3
  • 25
  • 52

8 Answers8

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.

Satyam Pathak
  • 6,612
  • 3
  • 25
  • 52
  • 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. – Adrian Kremer Nov 19 '20 at 09:42
22

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

Hefaz
  • 526
  • 1
  • 8
  • 24
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!.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Javier Carbajal
  • 111
  • 1
  • 2
4

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

Denise Ignatova
  • 465
  • 4
  • 7
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.

fotiecodes
  • 460
  • 6
  • 7
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.

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.

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.

Mark
  • 21
  • 4