Lesson 17 of 30
A version number that's actually a promise: MAJOR.MINOR.PATCH, where each position means something specific about what kind of change happened — not just an incrementing counter.
11 min read
Every option explains itself — why the right one is right, and why each wrong one is wrong. Miss one and it comes back later on a spaced-repetition schedule.
Question 1 of 2
package.json lists `"lodash": "^4.17.21"`. Does npm/pnpm guarantee your install always resolves to exactly 4.17.21?
Hints without spoilers, and a plain explanation of why a wrong answer was wrong — answered only from this lesson. Free account, no card.
Sign up freeWhat interviewers actually ask about this, and what a strong answer has to cover.
A strong answer covers
Likely follow-ups
Semantic Versioning (semver) gives MAJOR.MINOR.PATCH (e.g. 2.4.1) a precise meaning:
"dependencies": {
"lodash": "^4.17.21" // ^ allows 4.x.x, but not 5.0.0
}
^ (caret) allows any MINOR or PATCH update but blocks MAJOR — the standard default, trusting that a MINOR/PATCH bump genuinely won't break your code. ~ (tilde) is stricter, allowing only PATCH updates.
1.4.2 → MAJOR.MINOR.PATCH — each number means something specific about what changed.
package.json's version ranges (^4.17.21) don't pin an exact version — two different pnpm install runs, days apart, could resolve to different actual versions within that range, unless a lockfile (pnpm-lock.yaml) pins the exact resolved versions for reproducible installs.--frozen-lockfile fails the build if package.json and the lockfile have drifted apart, catching a class of "works locally, breaks in CI" bugs before they ship."What's the difference between ^1.2.3 and ~1.2.3 in package.json, and why does a lockfile matter?" is a very practical, common question — knowing that semver is a convention (not an enforced guarantee) and that lockfiles are what actually pin reproducibility shows real day-to-day dependency-management experience.