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.

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

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

2.Create user in NPM Registry.

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

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...

4.Publish your node module of fisrt version.

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

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.

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 patch

  • "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 publish

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.1

b. Or you can unpublish totally.

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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值