Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

What's the difference between tilde(~) and caret(^) in package.json?

After I moved up to the most recent stable node and npm, I attempted npm install moment - save. It saves the passage in the package.json with the caret ^ prefix. Already, it was a tilde ~ prefix.

1. For what reason are these progressions made in npm?

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

3. What are the benefits over others?
by

3 Answers

akshay1995
~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.
RoliMishra
~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.
kshitijrana14
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.

Login / Signup to Answer the Question.