Practical developer guides
SemVer ranges: caret, tilde and prerelease versions
Compare versions numerically and inspect npm-style ranges, especially for zero-major and prerelease versions.
Version strings are not plain text order
SemVer has major, minor and patch numeric components. Comparing the strings lexicographically can put 1.10.0 before 1.9.0.
Use a SemVer parser to compare valid versions. Build metadata does not affect precedence under the specification.
1.9.0 < 1.10.0
1.2.3+build.1 and 1.2.3+build.2 have equal precedence.Caret and tilde are package range rules
SemVer defines versions; package managers define range syntax. Under node-semver, ~1.2.3 allows patches below 1.3.0, while ^1.2.3 allows versions below 2.0.0.
Nav Tools uses node-semver for range checks. Another ecosystem’s compatible-version operator may have different rules.
Zero-major and prerelease require care
Caret behavior narrows for zero-major versions: ^0.2.3 stays below 0.3.0 under node-semver. Do not assume every caret means accepting a new minor version.
Prereleases are excluded from many range matches by default unless the range admits the relevant prerelease tuple. Test the exact candidate rather than guessing.
^0.2.3: 0.2.9 accepted; 0.3.0 rejected
~1.2.3: 1.2.9 accepted; 1.3.0 rejectedRanges do not prove compatibility
A package can violate its declared compatibility promises. A successful range match only answers whether the version satisfies the specified syntax.
Keep a lockfile and run meaningful integration checks for upgrades. Review release notes and runtime requirements separately from version range membership.