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

发布时间:2019-06-15 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了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

脚本宝典总结

以上是脚本宝典为你收集整理的03. 【Node.js Module】Publish a Node.js Module to the NPM Registry全部内容,希望文章能够帮你解决03. 【Node.js Module】Publish a Node.js Module to the NPM Registry所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: