Gopal Roy
Gopal Roy

Reputation: 1039

Getting Error 402 while publishing package using npm

I am using npm version 2.15.11 and node version 4.7.2 on ubuntu 14.04. I want to publish my packages. when i use the command:

npm publish

i am geting the error: You need a paid account to perform this action. For more info, visit: https://www.npmjs.com/private-modules

Below is the screenshot of error: enter image description here

Please provide me the solution to overcome this issue. Thanks in advance.

Upvotes: 66

Views: 32795

Answers (5)

noooooooob
noooooooob

Reputation: 1890

Just want to add that, if you tried all the other answers and still get this error, someone(maybe yourself) could have somehow changed the package to private previously, in which case, you need to set the package to public before you could publish again... Orz

Upvotes: 2

Carnaru Valentin
Carnaru Valentin

Reputation: 1855

In package.json, npm version 6+ you have this option:

"private": true/false,

Be sure is false, and also try to use this flag:

npm publish --access=public

Upvotes: 13

jos
jos

Reputation: 591

In addition to the command line option provided by bersling, you can merge the following into your package.json:

{
  "publishConfig": {
    "access": "public"
  }
}

Reference in npm documentation. Useful when you want to template it into your package manifests and not think about it.

P.S. had one of those old OpenId accounts, forgot to update it before it was nuked, no longer have the ability to add this as a comment to bersling's reply, which is where I feel this really belongs.

Upvotes: 49

bersling
bersling

Reputation: 19242

Run

npm publish --access=public

the first time you publish a scoped package.

The default access setting is private, but for this you need a paid account. Hence the error message.

Upvotes: 163

Leonid
Leonid

Reputation: 738

you probably initialized your package with a scope so that it is private. Read https://docs.npmjs.com/private-modules/intro

Upvotes: 2

Related Questions