Yarn
Yarn is a package manager for the JavaScript ecosystem, created as an alternative to npm. Its job is to manage a project's dependencies — installing, updating and removing the external libraries an application relies on — in a way that is fast, predictable and reproducible across different machines.
Why Yarn was created
Yarn appeared to solve problems that, in early versions of npm, could be painful: slow installs, non-deterministic results (the same project could install slightly different dependency versions on two computers) and the lack of a convenient offline cache. It introduced a dependency lock file guaranteeing that everyone on the team and every environment uses exactly the same versions, along with mechanisms to speed up repeat installs.
Yarn in practice
In daily work, Yarn installs the dependencies defined in the project file and places them in a directory used by build tools such as webpack and frameworks such as Vue.js. It uses the same public package registry as npm, so both managers pull the same libraries — what differs is how they are fetched and managed. Over time npm caught up on most of Yarn's original advantages: it introduced its own lock file and sped up installs, while Yarn evolved further, among other things toward newer dependency-management architectures. As a result, the choice between them today is mainly a matter of team preference, habit and the configuration of an existing project rather than fundamental differences in capability. Both tools serve the same role: they let you draw on the vast ecosystem of ready-made JavaScript libraries in a controlled way.
Powiązane pojęcia
Najczęstsze pytania
Does Yarn replace npm?
Yarn uses the same package registry as npm and is an alternative to it, not a successor. Modern npm has caught up on most differences, so the choice today is mainly a matter of team preference and the project's existing setup.
