Dependency Resolution on One Page
When someone installs your package, their package manager has to turn a pile of version ranges into one concrete set of files. Each ecosystem does this differently, and those differences decide whether your users end up with one copy of a dependency or three. Below, the essentials are laid out as labelled blocks, each written so it could stand as the caption of a panel in a printed infographic.
Panel 1: inputs and outputs
"lodash": "^4.17.0" or requests>=2.28,<3. A range is a promise about compatibility, not a pin.Alt-text description: two boxes side by side, an arrow from "ranges you write" on the left to "exact versions installed" on the right, with the label "resolver" on the arrow.
Panel 2: four strategies, four outcomes
| Ecosystem | How it picks | Copies of one package |
|---|---|---|
| npm and similar Node.js managers | Highest version satisfying each range; nested node_modules when ranges conflict. | Several versions can coexist in one install. |
| pip | Backtracking resolver seeks one version of each package that satisfies every requirement. | One per environment; conflicts are errors. |
| Go modules | Minimal version selection: the lowest version that meets every module's stated minimum. | One per major version; a new major is a different module path. |
| Cargo | Highest compatible version per semver-compatible range, unified where possible. | One per semver-incompatible range; two majors may coexist. |
Alt-text description: a four-row grid, each row a small tree diagram; the npm row shows a branch with two differently coloured copies of the same package, the pip row shows a single copy with a red "conflict" badge on an alternative branch.
Panel 3: what this means for library authors
- Wide ranges, tested ends. Accept the widest range you genuinely support, and test against both the lowest and the newest versions in it.
- Do not ship a lockfile as a constraint. Libraries' lockfiles are not used by consumers' installs in npm, pip or Cargo; they only make your own CI reproducible.
- Singleton dependencies need care. If two copies of a framework would break things, declare it as a peer dependency (npm) rather than a regular one.
- Go authors set floors. Because Go picks the minimum, the version in your
requireline is what many users will actually get. Raise it deliberately.
Panel 4: the lockfile in one sentence
A lockfile records what was resolved last time, so the next install on another machine gets the same answer until someone asks for a change.
Examples include package-lock.json, pnpm-lock.yaml, Cargo.lock and go.sum; note that go.sum holds checksums rather than choices, since go.mod already determines the versions. For a fuller explanation, see the annotated npm dependency tree tutorial and the guide to peer dependencies.