Wednesday, May 20, 2020

npm semantic versioning

NPM uses Semantic package versioning, which is a 3 part versioning like 7.5.5
<Major version>.<Minor version>.<Patch version>

Patch version – Patch versions will includes bug fixes
Minor version – Minor versions will include feature additions without breaking changes
Major version – Major version changes can include breaking changes

Caret wildcard (minor version)

Notice that the version numbers have a caret sign (^) in front of it in the package.json. By default npm adds this wildcard caret symbol before the version number, which signifies that when npm install is run against this package.json it can pick up the latest patch or minor version of the package, but the major version should not be changed.

For example we have react version ^16.8.6 in the package.json file, which is the latest version as of writing this post. Let’s say version 16.8.7 or 16.9.1 is released in a couple of months and anyone who runs npm install against this package specification will get the latest version available at this time and not 16.8.6. The caret (^) symbol allows the user to pick any updates to the minor or patch version but retains the same major version.

The caret (^) symbol is one of the many wildcard patterns available in npm versioning, apart from this there are many other symbol specifications to mention a specific or range of valid versions, let us look into this in the next post.

Tilde wildcard (patch version)
The tilde (~) wildcard represents a range for the patch version.  The pattern ~16.8.3 represents the range between 16.8.3 and 16.8.9. When the package.json has this pattern it can pick any higher patch version but not minor or major version.

* Wildcard
The * wildcard represents any version number in the placeholder where the * is mentioned. The pattern 16.8.* can take any value 16.8.0 to 16.8.9 for patch release. Similarly 16.* represents any version that starts with 16 and can be in the range 16.0.0 to 16.9.9

Range wildcard
The range (-) wildcard specifies a specific range of acceptable versions, the pattern 16.8.3 – 16.8.7 accepts any version in the given range.


Search Flipkart Products:
Flipkart.com

No comments: