Yarn is a package manager for JavaScript, announced by Facebook engineering on October 11, 2016 in a post titled “Yarn: A new package manager for JavaScript.” Facebook built it to address problems they hit running npm at scale: installs were slow, and the same package.json could produce different installed trees on different machines. Yarn stayed compatible with the existing npm registry, so it was a drop-in replacement rather than a new ecosystem.
The launch post describes Yarn’s core ideas. It “resolves these issues around versioning and non-determinism by using lockfiles and an install algorithm that is deterministic and reliable.” A lockfile records the exact version of every package in the dependency tree, so an install today reproduces the same result later. Yarn also keeps a global cache directory, letting developers “work offline” and avoid downloading the same dependency more than once.
Speed was a headline claim. Facebook reported that “on some Facebook projects, Yarn reduced the install process by an order of magnitude, from several minutes to just seconds.” It achieved this by splitting work into resolution, fetching, and linking stages and parallelizing them.
Yarn’s arrival pushed npm to improve; npm later added its own lockfile (package-lock.json). The official site at yarnpkg.com now describes Yarn as “a package manager that doubles down as project manager,” with a workspaces-first design and a guarantee of reproducible installs, and positions itself as “a fully independent open-source project tied to no company.”