Yarn is a JavaScript package manager originally released by Facebook in 2016 and now maintained by the open-source community, free to use under an MIT-style license. It ranks #11 among dev tools in usage surveys at roughly 21.1% share. It was created to fix early npm's slow, non-deterministic installs — Yarn introduced a lockfile that guarantees the exact same dependency tree on every machine, plus faster, parallelized installs, and remains a popular npm alternative across JavaScript projects.
Yarn commands mirror npm's workflow closely — add a dependency, then install the full tree from the lockfile.
# add a dependency to package.json + yarn.lock
yarn add react react-dom
# add a dev-only dependency
yarn add --dev typescript
# install everything from an existing yarn.lock (e.g. in CI)
yarn install --frozen-lockfile
# run a script defined in package.json
yarn run build
Yarn installs via npm itself (or Corepack, which ships with modern Node) so it can manage the very ecosystem it replaces.
# install Yarn globally via npm
npm install --global yarn
# or, with Node 16.10+, enable Corepack (no separate install needed)
corepack enable
# verify
yarn --version