Important: This documentation covers modern versions of Yarn.
For 1.x docs, see
IntroductionInstallationUsageEditor SDKsMigrationQuestions & AnswersRecipes


Edit this page on GitHub

Install Corepack

The preferred way to manage Yarn is through Corepack, a new binary shipped with all Node.js releases starting from 16.10. It acts as an intermediary between you and Yarn, and lets you use different package manager versions across multiple projects without having to check-in the Yarn binary anymore.

Node.js >=16.10

Corepack is included by default with all Node.js installs, but is currently opt-in. To enable it, run the following command:

corepack enable

Node.js <16.10

Corepack isn't included with Node.js in versions before the 16.10; to address that, run:

npm i -g corepack

Updating the global Yarn version

Node.js ^16.17 or >=18.6

corepack prepare yarn@stable --activate

Node.js <16.17 or <18.6

Take a look at the latest Yarn release, note the version number, and run:

corepack prepare yarn@<version> --activate

Initializing your project

Just run the following command. It will generate some files inside your current directory; add them all to your next commit, and you'll be done!

yarn init -2

Note: By default, yarn init -2 will setup your project to be compatible with Zero-Installs, which requires checking-in your cache in your repository; check your .gitignore if you wish to disable this.

Note: In case you're migrating from Yarn 1.x and hit a blocker, you might want to take a look at our Migration Guide. It isn't always needed, but a fairly comprehensive resource of how to solve issues that may arise in the transition.

Updating to the latest versions

Any time you'll want to update Yarn to the latest version, just run:

yarn set version stable

Yarn will then configure your project to use the most recent stable binary. Don't forget to run a new install to update your artifacts before committing the results!

Installing the latest build fresh from master

From time to time even the most recent releases aren't enough, and you then will want to try out the very latest master branch to check if a bug has been fixed. This has become very simple! Just run the following command:

yarn set version from sources

Similarly, specific PRs can be installed using the --branch flag:

yarn set version from sources --branch 1211