Thursday, 1 March 2018

node.js - 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.





  1. Why are these changes made in npm?

  2. What is the difference between tilde ~ and caret ^?

  3. What is the advantages over others?


Answer



See the NPM docs




~version “Approximately equivalent to version”, will update you to the next patch version. See semver. ~1.2.3 will use releases from 1.2.3 to <1.3.0.




^version Will update you to the next minor version. See semver. ^2.3.4 will use releases up to 3.0.0. See Comments below.



No comments:

Post a Comment

casting - Why wasn&#39;t Tobey Maguire in The Amazing Spider-Man? - Movies &amp; TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...