03. 【Node.js Module】Publish a Node.js Module to the NPM Registry

I'm practicing my English ability lately in order to be recruited by a foreign company for my next job-hopping,if there is anything that I did't express precisely, please pardon me.node

1.Make sure you have created a node.js module locally.

Check out your package.json, "name" and "version" are requiredexpress

2.Create user in NPM Registry.

Use the add user command to set your Username, Password and Email with the hint.
npm addusernpm

3.Checkout if your user account has been created, and verify your Email.

Go to https://www.npmjs.com/~[username], and verify your Email.
e.g: https://www.npmjs.com/~willbu...json

4.Publish your node module of fisrt version.

Enter your module's directory, then use the publish command.
npm publishsegmentfault

some error occured to me:
1.【problem】: You do not have permission to publish "sayhelloworld". Are you logged in as the correct user? : sayhelloworld
【how to solve】: There is a node module with the same name of your's in the NPM Registry already, you need to change your node module's name.
2.【problem】: You must verify your email before publishing a new package】
【how to solve】: You need to verify your email as the step 3 said.
3.【problem】: You must be logged in to publish packages
【how to solve】: Use command npm login to login first.ui

5.If you want to republish after changing your module function, you need to change your version first.

Use the version command to change your module's version.

npm version [version level] // e.g: npm version patchcode

  • "major": bump your version of the major version
  • "minor": bump your version of the minor version
  • "patch": bump your version of the patch level

Republish your node module.

npm publishci

6.You can unpublish your node module before.

a.You can unpublish by version.

npm unpublish [module name]@[module version] // e.g: npm unpublish hellowWorld@v1.0.1get

b. Or you can unpublish totally.

npm unpublish [module name] --froce // e.g: npm unpublish hellowWorld --forceit

Related:
Create a Node.js Module and Use it Locally
Install Pakages Using NPM

相關文章
相關標籤/搜索