npm包版本号语义解析

目标 实现 实例
include everything greater than a particular version in the same major range use the carat (aka hat) symbol, ^ ^2.2.1
include everything greater than a particular version in the same minor range use the tilde symbol, ~ ~2.2.0
specify a range of stable versions use >, <, =, >= or <= for comparisons, or - to specify an inclusive range >2.1 or 1.0.0 - 1.2.0
include prerelease versions like alpha and beta use the prerelease tag 1.0.0-rc.1
include multiple sets of versions use || to combine `^2 <2.2
specify a range of prerelease versions use comparisons like > with a prerelease tag >1.0.0-alpha or >=1.0.0-rc.0 <1.0.1

版本号增加规则

Code status Stage Rule Example version
First release New product Start with 1.0.0 1.0.0
Backward compatible bug fixes Patch release Increment the third digit 1.0.1
Backward compatible new features Minor release Increment the middle digit and reset last digit to zero 1.1.0
Changes that break backward compatibility Major release Increment the first digit and reset middle and last digits to zero 2.0.0