How it works
Yarn arrived when npm was slow and installs were unpredictable, and it introduced ideas npm later adopted: a lockfile (yarn.lock), parallel downloads and workspaces for monorepos. Yarn Classic (version 1) now only receives maintenance fixes, yet many older projects still use it.
Modern Yarn (often called Berry) is a rewrite. Its Plug'n'Play mode drops the node_modules folder in favour of a single map of where each package lives, which makes installs quick and dependency errors strict, and zero-installs lets a repository commit its package cache so a fresh clone runs without installing. Some tools need extra setup for Plug'n'Play, so Yarn can also use a normal node_modules folder.
Yarn pricing
Yarn vs the alternatives
Related terms
More in Dev workflow and DevOps
Packages