In the folder, npm initinitialize the project information to generate package.json
Create a new index.js, the file name and path are actually implemented in package.json:"main": "index.js",
index.js write content, such as
alert('这是一个npm测试包,功能就是弹出这句话')
Make sure the source of npm points to the official
yarn config get registry
yarn config set registry https://registry.npmjs.org
After registering on the npm official website, log in to the project, enter the password, and possibly the verification code received by email
npm login // 登录
npm whoami // 看看当前账户名称
release. If the package name starts with @, it is private by default, and it can be published normally only after adding –access public for the first time, and there is no need to add it later.