Sementic Versioning is an unofficial standard used to describe changes to your software versions. It uses a tuple of numbers where the first is the Major version, the second is Minor, and the final is the Patch version.
For example, using jQuery 2.1.8.
2 = Major version
1 = Minor version
8 = Patch version
Given a version number MAJOR.MINOR.PATCH, increment the:
Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
Use the npm semver calculator to see how the below ranges will work.
npm’s package.json
and Bower’s bower.json
files often include dependencies to the project. When including external packages you can specify an exact version, a range, greater than, etc.
The primitive operators are: >, >= , <, <=, and =. Boolean logic operators are: space = And, || = Or.
Advanced syntax operators are: ~, ^, –, and x. Each of these can actually be written using the primitive operators, but provide for a shortened syntax.
In the examples below, remember that a space is a boolean AND.
~1.2.3
same as >=1.2.3 <1.3.0
~1.2
same as >=1.2.0 <2.0.0
Assuming library authors follow SymVer rules correctly, this is the most useful syntax (specifying Major and Minor tuples with the tilde). Example: {"jQuery": "~1.9"}
Use any version of jQuery greater than or equal 1.9.0 and less than the 2.x version.
Allows changes that do not modify the left-most non-zero digit in the [major, minor, patch] tuple. Do not use — this is more clearly expressed using the primitives syntax.
Inclusive range between two versions. If there are missing tuples, they will be replaced with zeros.
1.2 - 2.4.3
same as >=1.2.0 <=2.4.3
You can use x, X, or * as a wildcard character.
1.2.x
same as >=1.2.0 <1.3.0