by Samy (Kondasamy Jayaraman)

Module 42 · Dependencies

Intermediate

The code you did not write

Most of an app is packages other people wrote, stacked on each other. Here you install Larkspur’s shop app from a made-up registry, pull crates out of its tower, and pick how it takes updates.

Read as

The whole idea in one example

Same code, two mornings

Day 10

passed

pricebook 1.4.2

The build installs, tests and ships.

Day 11

broken

pricebook 1.4.3

A new patch slipped in through a caret range. Nobody changed a line.

Every package, version and day here is fictional, from a registry written for this module.

How it works

Four ideas carry the module

  1. 1 Packages stand on packages

    Name 5, get the ones they need too

  2. 2 A range lets updates in

    The same ranges install newer releases a week later

    npm’s version-range rules expand ^1.2.3 to >=1.2.3 <2.0.0, ^0.2.3 to >=0.2.3 <0.3.0, and ~1.2.3 to >=1.2.3 <1.3.0.

    Source, checked 30 October 2026

  3. 3 The lockfile decides when

    Installs repeat until a tested update moves it

    npm’s docs say its lockfile describes the exact tree installed, so later installs can build identical trees whatever new releases come out in between, and it is meant to be saved with the code.

    Source, checked 30 October 2026

  4. 4 A stranger’s release

    Pins and scripts off miss it; the lockfile keeps it out

    npm’s write-up says an attacker took over maintainership of event-stream and, on 9 September 2018, added a dependency, flatmap-stream, whose version 0.1.1 hid code aimed at a bitcoin wallet app; it was reported on 26 November 2018.

    Source, checked 28 October 2026

The story

Larkspur’s broken morning

Larkspur’s shop app pulls in packages it did not write; one morning its build breaks without a code change, and the team learns that a range lets updates in and the lockfile decides when. You’re on the team that owns the shop’s build.

5
packages Larkspur’s shop app names
9
packages its install brings
30
days in the registry’s month, the one every chapter runs
4
policies tie chapter 7

Your path

The chapters

  1. Chapter 1

    Code you did not write

    What does installing the app bring in?

  2. Chapter 2

    What the numbers mean

    Which new versions does a range let in?

  3. Chapter 3

    Packages need packages

    What happens when two packages need different versions of one?

  4. Chapter 4

    The same install every time

    How do two installs of the same app come out the same?

  5. Chapter 5

    One bad patch

    How does a bad release reach an app nobody changed?

  6. Chapter 6

    Who published this?

    What keeps a hijacked release out of the app?

  7. Chapter 7

    An update policy

    Which policy keeps every build safe and takes the fix soonest?

Who it’s for

  • Engineers
  • Product managers
  • Analysts
  • No code needed

Anyone whose product ships code it did not write, which is nearly everyone, and who wants to know why a build breaks overnight and what a lockfile, the list of exact versions, is for. Git covers history and merging; this module covers versions and how an install picks them.