Interview Q&A / Node.js

BeginnerQuick answer1 min readUpdated 3 Oct 2026

What is semantic versioning and why does it matter for npm packages?

SHORT ANSWER

Semantic versioning uses MAJOR.MINOR.PATCH. Increase PATCH for bug fixes, MINOR for backward-compatible features, MAJOR for breaking changes, so users can judge upgrade risk from the number alone.

Explain it simply

Think of a mobile app update. A tiny bug fix should not change how the app looks. A big redesign might move your buttons around. Semantic versioning, or semver, gives each kind of change its own number so you know what to expect before you update.

Given version 3.7.2:

  • 3 is MAJOR: incompatible API change. Your code may need edits.
  • 7 is MINOR: new feature added, old code still works.
  • 2 is PATCH: bug fix only.

When a major number goes up, minor and patch reset to zero, so 3.7.2 becomes 4.0.0 after a breaking change.

Example

bash
npm version patch   # 1.4.2 -> 1.4.3
npm version minor   # 1.4.3 -> 1.5.0
npm version major   # 1.5.0 -> 2.0.0

npm version also creates a git commit and a tag by default. Ranges like ^1.4.2 in package.json depend on authors following semver, since npm will happily install a new minor version automatically.

Versions below 1.0.0 are treated as unstable; the author may break things in a minor release.

What to say in the interview

"Semver is MAJOR.MINOR.PATCH: breaking, feature, fix. Package managers use it to decide which updates are safe to auto-install, so publishing a breaking change as a patch would break everyone's builds."

Common mistakes

  • Publishing a breaking change as a minor or patch release.
  • Assuming every package follows semver strictly; the lock file protects you.

#npm#semver#versioning

Related questions

Practise more Node.js questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Node.js quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.