1. Register an npm account
I won’t do a demonstration here.
2.Initialize npm
Create project folder
Project terminal opens
npm init
Initialize according to the configuration (*The project name must be checked on the npm official website to see if it is duplicated)
After initialization, you need to put the code that needs to be uploaded into the folder.
3. Upload the code
Add users to the project
npm adduser
If you use Taobao mirror, you must switch back to npm.
method:
npm config list //可查看你当前的 npm 配置
npm config set registry https://registry.npmjs.org/ //npm 源更换为 npm 官方源
After npm adduser
You need to enter Username (npm account) Password (npm password)
Email(npm mailbox)
after
You will receive a verification code by email
Can be published after submission for verification
4.Publish
npm publish //再发布
npm config set registry=http://registry.npm.taobao.org/ //配置完之后可以切回淘宝源
Then you can check your code package from the npm official website