Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Error 402 while publishing package using npm

Tags:

node.js

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.

like image 322
Gopal Roy Avatar asked Feb 01 '17 14:02

Gopal Roy


People also ask

How do I fix npm installation errors?

If your npm is broken: On Mac or Linux, reinstall npm. Windows: If you're on Windows and you have a broken installation, the easiest thing to do is to reinstall node from the official installer (see this note about installing the latest stable version).

Why npm install is showing error?

code 1 error usually occurs when you run the npm install command. This cause of this error is that one of the dependencies you define in your package. json file fails to be installed properly on your computer. This means that npm fails to install the node-sass module that's added as a dependency to the n-app project.


2 Answers

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.

like image 136
bersling Avatar answered Oct 18 '22 08:10

bersling


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.

like image 45
jos Avatar answered Oct 18 '22 07:10

jos