Package Versioning :
QA 1 :
What’s the difference between tilde(~) and caret(^) in package.json ?
After I upgraded to latest stable node and npm, I tried npm install moment –save. It saves the entry in the package.json with the caret ^ prefix. Previously, it was a tilde ~ prefix.
Why are these changes made in npm?
What is the difference between tilde ~ and caret ^?
What is the advantages over others?
Solution 1 :
~version “Approximately equivalent to version”, will update you to all future patch versions, without incrementing the minor version. ~1.2.3 will use releases from 1.2.3 to <1.3.0.>
^version “Compatible with version”, will update you to all future minor/patch versions, without incrementing the major version. ^2.3.4 will use releases from 2.3.4 to <3.0.0.>
The tilde (~)
In the simplest terms, 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 (^)
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.
Tilde Version Range (~) - ~1.2.3 is equivalent to >=1.2.3 <1.3.0
Caret Version Range (^) - ~1.2.3 is equivalent to >=1.2.3 <2.0.0
1. Installing exact package versions :
npm config set save-prefix ‘~’ – Make default tilde (~) instead of caret (^)
npm config set save-exact true – make –save –save-exact default behaviour
npm install
2. Updating Packages
npm update – Update to latest versions that satisfy semantic versioning ranges in package.json
npm outdated – List packages that have newest versions available
npm install
<major>.<minor>.<patch>-beta.<beta> == 1.2.3-beta.2
npm --version
if version 3.10.10, it will use “Flattening Dependency Algorithm “. In this algorithm Depending on which module downloaded first the flattening of dependency will applied
npm uninstall node-sass npm install node-sass@4.14.1 npm install --save-dev --unsafe-perm node-sass
Reference
Nodejs Release
bcrypt Version
node-sass Version
Difference-between-tilde-and-caret
Dependency resolution in npm — How npm downloads node modules
NPM Tutorials
bcrypt
sass