I have time today to study how to publish npm packages before myself. After doing it again, I found that it is very simple.
-
First of all, we have updated the package we want to update locally
. I have released this package before. This time I addedKeepDecimal.js
a new file, which mainly realizes the retention of decimals with a specified number of digits, padding with zeros if the number is less than the specified number of digits, and exceeding the specified number of digits. The specified number of digits is rounded. -
After editing the code we want to update, in the terminal, cd to the root directory of our project and execute it. At
npm login
this time, we will be asked to enter the npm account number, password, and email address in turn. Through the email address, npm will send a verification code and enter it for verification. The code is verified, and after the verification is successful, the login is successful -
At this point, we only need to execute, , which is in the file
npm version patch
in our project , and it will increase automatically. Note, do not modify at will , the corresponding package will be updated according to the name. I have auto - incremented frompackage.json
version
name
npm
package.json
version
1.0.2
1.0.3
-
Finally, execute it
npm publish
, and the following information will appear. At this point, our package is updated.
-
Finally, take a look at the npm official website