Member-only story
npm dependencies version(^ ~ || > < = ) formats — Complete Guide
npm packages follow the version numbering as per semantic versioning spec. The major takeaways of this specifications are
- New package starts with the version
1.0.0
[major, minor, patch] - Patch release versions increment the last digit
1.0.1
- Minor release versions increment the second digit and reset the last digit to zero
1.1.0
- Major release increment the first digit and reset the rest to zero
1.0.0
Usually we provide dependencies in package.json with list of packages needed for the application
Example : “lodash”: “^1.2.3”
We specify a special character before the version which relates to installation of the particular version range of the package
Caret ^
Don’t modify left-most non-zero element, include everything else
^1.2.3
:=>=1.2.3 <2.0.0
(Excluding 2.0.0)
Major release 1 is the left most non zero here, so that should not be changed, so version ranges will be include all the patch and minor versions
^0.2.3
:=>=0.2.3 <0.3.0
(Excluding 0.3.0)
Here Minor release is the left most non zero, so version ranges without incrementing second digits are valid, which is minor releases between that.
^0.0.3
:=>=0.0.3 <0.0.4