How to specify versioning when publishing your own npm library

for example, publish a library test

reference in other projects

npm install test

how to specify a version number preceded by ^

"test":"^0.0.1"

another problem is that I follow this configuration locally and then run npm install
. For example, the version of 0.0.2 on the server will theoretically be automatically installed to the 0.0.2 version, but it has not been upgraded. Why?
then check the information and say that you can use npm update , even if you try, so I came to ask the bosses how to do it.

Apr.18,2022

< H2 > directory < / H2 >

several symbols
install the class library
update the class library
references

< H2 > several symbols < / H2 >

^ -it is not allowed to change the first non-zero number on the left. For example:

'^1.2.3'  '>=1.2.3 <2.0.0'
'^0.2.3'  '>=0.2.3 <0.3.0'
'^0.0.2'  '>=0.0.2 <0.0.3' //

~ -allows minor digits to change. For example:

~1.2.3  >=1.2.3 <1.(2+1).0  >=1.2.3 <1.3.0
~1.2  >=1.2.0 <1.(2+1).0  >=1.2.0 <1.3.0 (Same as 1.2.x)
~1  >=1.0.0 <(1+1).0.0  >=1.0.0 <2.0.0 (Same as 1.x)
~0.2.3  >=0.2.3 <0.(2+1).0  >=0.2.3 <0.3.0
~0.2  >=0.2.0 <0.(2+1).0  >=0.2.0 <0.3.0 (Same as 0.2.x)

--- specifies the version of a certain range. For example:

//:
1.2.3 - 2.3.4  >=1.2.3 <=2.3.4
//:
1.2.3 - 2.3  >=1.2.3 <2.4.0
1.2.3 - 2  >=1.2.3 <3.0.0

x -- matches any number X. For example:

*  >=0.0.0 (Any version satisfies)
1.x  >=1.0.0 <2.0.0 (Matching major version)
1.2.x  >=1.2.0 <1.3.0 (Matching major and minor versions)
< H2 > install the class library < / H2 >

some syntax: npm install [< @ scope > /] < name > @ < version >
some examples:
/ / install a specified version
npm install test@0.0.2
/ / install a specified range version
/ / install a specified range version (greater than)
npm install test@ "> 0.0.1"
/ / install a specified range version (less than)
npm install test@ "< 0.0.1"
/ / install a specified range version (between)
npm Install test@ "^ 0.0.2"
npm install test@ "> = 0.0.2 < 0.0.3"

< H2 > Update the class library < / H2 >

some syntax: npm update [- g] [< pkg >...]
some examples:

//
npm update test
//
npm update test@"0.0.2"
//
npm update test@"^0.0.2" //npm update test@">=0.0.2 <0.0.3"
< H2 > references < / H2 >

npm- official document-install the English version of the library
npm- official document-Update the English version of the library
semver- arithmetic version


npm install test@x.x.x

if you don't update it after installation, it should be the version number of the .lock file constraint package.

Try changing the corresponding version number in

package-lock.json

Menu