Skip to content
EduVerse

Yarn

Mentioned

Tool

Alternative JavaScript package manager, originally built by Facebook.

Yarn, explained

Written by EduVerse

What it is

Yarn is a package manager for JavaScript and an alternative to npm. It reads the same package.json and installs packages from the same registry, but it uses its own lockfile, yarn.lock, and slightly different commands: yarn add instead of npm install for a new package, for example.

Why teams use it

Yarn was created at Facebook when npm was slower and had no lockfile, so installs could differ from one machine to the next. npm has since caught up on most of that, but switching a project over takes effort, so plenty of projects still use Yarn. The rule is simple: use whatever the project already uses.

An example from work

The project root contains yarn.lock, but out of habit you run npm install. Now a new package-lock.json shows up among your changes, and a reviewer asks you to remove it. You delete it, run yarn instead, and from then on add packages with yarn add.

Our own explanation, not a quote from the book.

Where it fits

Installing and managing JavaScript packages (an npm alternative)

Coverage in the book

Mentioned

Mentioned as part of the wider landscape, without in-depth coverage.

Appears in