DEV Community

dibeesh
dibeesh

Posted on

Difference between tilde(~) and caret(^) in package.json?

~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. ^1.2.3 will use releases from 1.2.3 to <2.0.0.

value desc
~version Approximately equivalent to version, i.e., only accept new patch versions See npm semver - Tilde Ranges
^version Compatible with version, i.e., accept new minor and patch versions See npm semver - Caret Ranges
version Must match version exactly
>version Must be greater than version
>>=version etc
>>1.2.x 1.2.0, 1.2.1, etc., but not 1.3.0
* Matches any version
latest Obtains latest release

Top comments (0)