Update your own published npm package

​​​​​​​​I have time today to study how to publish npm packages before myself. After doing it again, I found that it is very simple.

  1. First of all, we have updated the package we want to update locally
    insert image description here
    . I have released this package before. This time I added KeepDecimal.jsa 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.

  2. After editing the code we want to update, in the terminal, cd to the root directory of our project and execute it. At npm loginthis 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

  3. At this point, we only need to execute, , which is in the file npm version patchin 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.jsonversionnamenpmpackage.jsonversion1.0.21.0.3

insert image description here

  1. Finally, execute it npm publish, and the following information will appear. At this point, our package is updated.
    insert image description here

  2. Finally, take a look at the npm official website
    insert image description here

Guess you like

Origin blog.csdn.net/weixin_46801545/article/details/126605670