The module versions in NPM are subject to the semantic version rules of Semver 2.0.
Version format: Major version number. The minor version number. Revision number, the version number is incremented as follows: Major version number: When you make incompatible API modifications, the minor version number: When you do a backwards-compatible functionality added, revision number: When you do a backward-compatible problem fix. The prior version number and version compilation information can be added to the "major version number." Minor version number. The revision number is followed by an extension.
Then, based on the semantic version, we can control the dependency versioning when we select the version:
Dependencies: {"Express": "3.x", "Debug": "*", "express-session": "~1.0.0", "Connect-redis": "1.2.3"}
As you can see from the example, there are a number of styles for choosing a version range, which can be seen in the semver in NPM for each of the different styles. and in node. JS's module management, the most commonly used are:
*: Any version
1.1.0: Specify version
~1.1.0: >=1.1.0 && < 1.2.0
^1.1.0: >=1.1.0 && < 2.0.0
where ~ and ^ Two prefixes are confusing, simply put:
The ~ prefix indicates that the installation is larger than the specified version and matches the latest version of Z in x.y.z.
^ prefixes behave the same as ~0.y.z in ^0.y.z, but when ^1.y.z, they are matched to the newest versions of Y and Z.
Specifically, when the version number is ^0.0.Z or ~0.0.z, consider that 0.0.z is an unstable version, so they are equivalent to =0.0.z.
Nodejs NPM Module Version number mode parsing