What does the ^ symbol mean in the version of a dependency in package.json?
I couldn't find it in the docs.
For example:
"dependencies": { "grunt": "^0.4.4", ... } What does the ^ symbol mean in the version of a dependency in package.json?
I couldn't find it in the docs.
For example:
"dependencies": { "grunt": "^0.4.4", ... } I found an answer here:
The caret, on the other hand, is more relaxed. It will update you to the most recent major version (the first number).
^1.2.3will match any1.x.xrelease including1.3.0, but will hold off on2.0.0. npm’s semantic versioning parser clarifies the distinction:~1.2.3 := >=1.2.3-0 <1.3.0-0 "Reasonably close to 1.2.3". ^1.2.3 := >=1.2.3-0 <2.0.0-0 "Compatible with 1.2.3".― isaacs/node-semver (emphasis added)
For completeness, the canonical documentation from the semver repository is as follows:
Caret Ranges
^1.2.3^0.2.5^0.0.4Allows changes that do not modify the left-most non-zero element in the
[major, minor, patch]tuple. In other words, this allows patch and minor updates for versions1.0.0and above, patch updates for versions0.X >=0.1.0, and no updates for versions0.0.X.Many authors treat a
0.xversion as if thexwere the major "breaking-change" indicator.Caret ranges are ideal when an author may make breaking changes between
0.2.4and0.3.0releases, which is a common practice. However, it presumes that there will not be breaking changes between0.2.4and0.2.5. It allows for changes that are presumed to be additive (but non-breaking), according to commonly observed practices.
^1.2.3:=>=1.2.3 <2.0.0-0^0.2.3:=>=0.2.3 <0.3.0-0^0.0.3:=>=0.0.3 <0.0.4-0^1.2.3-beta.2:=>=1.2.3-beta.2 <2.0.0-0Note that prereleases in the1.2.3version will be allowed, if they are greater than or equal tobeta.2. So,1.2.3-beta.4would be allowed, but1.2.4-beta.2would not, because it is a prerelease of a different[major, minor, patch]tuple.^0.0.3-beta:=>=0.0.3-beta <0.0.4-0Note that prereleases in the0.0.3version only will be allowed, if they are greater than or equal tobeta. So,0.0.3-pr.2would be allowed.When parsing caret ranges, a missing
patchvalue desugars to the number0, but will allow flexibility within that value, even if the major and minor versions are both0.
^1.2.x:=>=1.2.0 <2.0.0-0^0.0.x:=>=0.0.0 <0.1.0-0^0.0:=>=0.0.0 <0.1.0-0A missing
minorandpatchvalues will desugar to zero, but also allow flexibility within those values, even if the major version is zero.
^1.x:=>=1.0.0 <2.0.0-0^0.x:=>=0.0.0 <1.0.0-0