I want to know the exact difference between the semver notations in package.json. Can someone explain me.
CodePudding user response:
Semver notation isn't specifically used
in package.json
.
If it's followed (*1), it helps developers to understand what to expect from any particular update. Imagine you want to bump the version of a library, and you see that the difference is in the major
part of the version (n in n.*.*
). This can point out to potential repercussions of upgrading the package - according to SEMVER MAJOR version when you make incompatible API changes,
.
*1 It's not always followed by developers. One prominent example is React Native. The developers have never released a Major version, and treat MINOR
as MAJOR
CodePudding user response:
I think the npm documentation explains it well: https://docs.npmjs.com/cli/v6/using-npm/semver#advanced-range-syntax
Since there is a lot going on, perhaps a brief explanation of the two most common:
The caret modifier (^) will automatically go the highest minor and patch version, unless the major version is 0. In this case, will only update the patch version.
The tilde modifier (~) will only go to the highest patch version. So ~ and ^ are equal when the major version is 0.