Lesson 1 · Unit 02
Dependencies
Semantic versions, ranges with ^ and ~, the lockfile, and what production needs
What you practise
- A manifest and what it declares, semantic versions and range syntax (
^,~), the lockfile and why it is committed, development against runtime dependencies
Try a question from this lesson
Pick one
You are on version 2.4.1 of a library. Three newer releases exist: 2.4.2, 2.5.0 and 3.0.0. Which upgrade most deserves a read of the release notes first?
Correct answer
3.0.0
Why
By convention the first number changes only when existing callers may break. A last-number bump should be fixes only, and a middle-number bump should only add. The numbers tell you how careful to be.
The ideas
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
Semantic versioning
A version reads MAJOR.MINOR.PATCH.
A patch fixes bugs and changes nothing callers can see. A minor adds features; old code keeps working. A major may break callers.
It is a promise by the author, not a law. Lockfiles and tests exist because promises get broken.
Concept
The manifest
The manifest (package.json in JavaScript, pyproject.toml in Python) declares what the project needs, as ranges: ^5.1.0 means "5.1.0 or any later 5.x".
Packages needed to run go in one list. Tools needed only to build and test go in another.
{
"name": "shop",
"version": "0.3.0",
"dependencies": {
"express": "^5.1.0"
},
"devDependencies": {
"vitest": "^3.2.0"
}
}Concept
The lockfile
A range can resolve to a different version every day. The lockfile (package-lock.json) records the exact version of every package in the tree, dependencies of dependencies included, each with a checksum.
Commit it. npm ci installs exactly what it lists, and fails if it disagrees with the manifest.
9 more exercises in the app
- 1× match the pairs
- 2× type the answer
- 4× multiple choice
- 1× true or false
- 1× fill the blanks
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.