SemVer Simplified: Major, Minor, Patch and Why They Matter
Why your code breaks at 3 AM and how SemVer saves you

The Problem First
Lets assume a situation where you have written code today and it works well. Next day you come and run:
cd backend
npm i
npm start
But it fails. Your code is the same, no new PR was merged but it still fails.
It is possible that an Express developer merged a new PR at 3 AM, and npm i installed that new version automatically.
Here comes Semantic Versioning also known as SemVer.
What is SemVer?
SemVer has 3 components like X.Y.Z
1. Major (X)
You increase this number when you make incompatible API changes or major changes that can break your existing code.
Example: "2.6.9" → "3.0.0"
NOTE: When you increase the Major version, you must reset Minor and Patch to 0.
2. Minor (Y)
You increase this when you add functionality in a backward-compatible manner. Here you add new features without touching the existing code — meaning the old code does not break.
Example: "2.6.9" → "2.7.0"
3. Patch (Z)
This is strictly for backward-compatible bug fixes. It involves minor internal improvements or fixing a mistake in existing code. It does not break your code. No new features, just improving existing code.
Example: "2.6.9" → "2.6.10"
Why Do We Need SemVer?
You can track your software history by numbers (e.g.,
V-2.5.6).It enables clear communication between the developer and the package maintainer.
In
package-lock.json, one dependency often depends on another. SemVer ensures that a small improvement in a deep dependency doesn't accidentally break the whole system
What is ^ and ~?
Caret (^)
Locks the leftmost non-zero digit and allows everything else to update. This means it allows Minor and Patch updates but blocks Major updates.
Tilde (~)
Only allows the last digit (Patch) to change. This means it allows Patch updates but blocks both Minor and Major updates.
Note Points
Initial Phase: Versions like
0.x.xare used for the initial development phase where the API is not yet stable. The first stable release is usually1.0.0.When you run
npm i, it automatically installs new versions based on^or~.npx @expressjs/codemod upgrade— This is Express-specific, not a general SemVer rule. Use it to update your Express code with new version changes.
About the author
- Failure is life's greatest teacher
Comments
Join the discussionNo comments yet. Be the first to comment.




