After everyone writes their first tool library (hereinafter called npm-project), they will publish it on the npm.js official website on a whim to try the effect. Let me talk about the release process of the tool library based on my own experience.
1. Fill in the basic information of the library you want to publish in the packjson of your own npm-project
{
"name": "twt_tools", //发布包的名称
"private": false, //公开还是私有
"version": "0.0.0", //版本号,每次更新的时候注意版本号的升级
"keywords": ["tools","twt_tools","twilight_tools"], //npm上搜索的关键词
"type": "module",
}
2. Enter the npm-project and execute npm login
the command to log in to the npm official website. Enter your user name, password, and registered email address in turn, and a verification code will be sent to your email address when you are done.
3. Make sure that the above four items are filled out and used to npm publish
publish. At first, I waited for a day for the first release, but there was no result, thinking that the review time would take a long time. In fact, it is not the case. Before publishing, you need to use nrm to confirm the mirror source of your npm connection. When I publish, I use the company’s own mirror. When you usually use npm, you may also use Taobao’s mirror, so you need to switch back to the npm mirror when publishing.
4. After the release is successful, log in to https://www.npmjs.com/ and you should be able to see the package you released
But don’t publish your own npm-project too frequently, but you still need to self-test after writing it yourself, so is there any way to test it locally?
The official way is to use npm link, I still use the global warehouse of yalc to solve the problem
Install globally first
npm install yalc -g
In the tool library npm-project npm run build && yalc publish
In your own project my-projectyalc add npm-project
Eyes in my-projectyalc add npm-project
Note that yalc add takes the name in package.json in npm-project