What is Semantic Versioning?
You'll learn how version numbers communicate the nature of changes in a package, helping you understand compatibility at a glance.
The Version Number Format
Semantic Versioning (often called "SemVer") is a standardized way to assign meaning to version numbers. Every version follows the format:
MAJOR.MINOR.PATCH
For example: 2.4.7 or 1.0.0.
What Each Number Means
MAJOR (the first number): Incremented when you make breaking changes that are incompatible with previous versions. If a package goes from 1.x.x to 2.0.0, expect your code might break if you update.
MINOR (the middle number): Incremented when you add new features in a backward-compatible way. Going from 2.3.x to 2.4.0 means new functionality exists, but existing code still works.
PATCH (the last number): Incremented for backward-compatible bug fixes. A change from 2.4.7 to 2.4.8 fixes problems without adding features or breaking anything.
An Analogy
Think of a restaurant menu:
- MAJOR: The cuisine changes entirely (Italian → Chinese)
- MINOR: New dishes added to existing cuisine (added pasta options)
- PATCH: Fixed typos or corrected prices on existing items
Why It Matters for JavaScript
When you see a dependency like ^2.4.7 in your package.json, you're relying on SemVer promises. The caret (^) tells NPM "any version from 2.4.7 up to (but not including) 3.0.0 is acceptable," trusting that MINOR and PATCH updates won't break your code.
Key Takeaway: Semantic Versioning uses three numbers (MAJOR.MINOR.PATCH) to communicate whether an update contains breaking changes, new features, or just bug fixes—helping you make informed decisions about updating dependencies.