Symbols in the version field of package.json
You may have seen something like the following code before in package.json and may be puzzled about the symbols like '<>~^'.
Code:
{ "dependencies" :
{ "foo" : "1.0.0 - 2.9999.9999"
, "bar" : ">=1.0.2 <2.1.2"
, "baz" : ">1.0.2 <=2.3.4"
, "boo" : "2.0.1"
, "qux" : "<1.0.0 || >=2.3.1 <2.4.5 || >=2.5.2 <3.0.0"
, "asd" : "http://asdf.com/asdf.tar.gz"
, "til" : "~1.2"
, "elf" : "~1.2.3"
, "two" : "2.x"
, "thr" : "3.3.x"
, "lat" : "latest"
, "dyl" : "file:../dyl"
}
}
Here are the definitions I found in https://docs.npmjs.com/files/package.json.
version
Must matchversion
exactly>version
Must be greater thanversion
>=version
etc<version
<=version
~version
"Approximately equivalent to version" See semver^version
"Compatible with version" See semver1.2.x
1.2.0, 1.2.1, etc., but not 1.3.0*
Matches any version""
(just an empty string) Same as*
version1 - version2
Same as>=version1 <=version2
.range1 || range2
Passes if either range1 or range2 are satisfied.
评论
发表评论