Tilde(~) vs Caret(^) in Package.json
13 September, 2018 | 3 min read
Let’s start describing how versioning works:
Semver explained easy
Semantic Versioning helps us to understand what kind of changes cause the version number to be incremented. Semver uses three part version number like 3.9.2 and call these three numbers from left to right as the major, minor and patch numbers. As the table shows below
Major Number Version
Major version numbers change whenever there is some significant change being introduced. For example, a large or potentially backward-incompatible change to a software package.
Minor Number Version
Minor version numbers change when a new, minor feature is introduced or when a set of smaller features is rolled out.
Patch Number Version
Patch numbers change when a new build of the software is released to customers. This is normally for small bug-fixes or the like.
After understanding how Semantic Versioning works and what kind of changes are introduced by each number lets talk about the symbols in package.json
The tilde (~)
The easy way to understand this, the tilde (~) matches the most recent minor version (the middle number). ~1.2.3 will match all 1.2.x versions but will miss 1.3.0.
The caret (^), on the other hand, is more relaxed. It will update you to the most recent major version (the first number). ^1.2.3 will match any 1.x.x release including 1.3.0, but will hold off on 2.0.0.
Other options for versioning in package.json
||Approximately equivalent to version|
||Compatible with version|
||Must match version exactly|
||Must be greater than version|
||Must be greater or equal than version|
||Must be less than version|
||Must be less or equal than version|
||This may be the URL of a tarball which will be downloaded and installed locally|
||Matches any version|
||Obtains latest release|
Thanks for reading this post hope it help you a bit to understand forms in angular. Have an amazing day!