This lesson goes over how to install yarn 2 through npm.
To install yarn 2 globally, we use npm install -g yarn@berry
.
To install yarn 2 to a specific project, we use yarn policies set-version berry
. This creates a .yarnrc
file and a .yarn/
directory. .yarnrc
that sets the path to our yarn instance in the created .yarn/
directory that holds our new yarn version.
Instructor: [00:00] Right now, I'm in an empty directory. My Yarn version is 1.21.1. If I wanted to install Yarn 2 globally, I would run npm install -g yarn@berry. I'm going to install it locally though. First, I need to yarn init -y. Y just says yes to any questions yarn init asks.
[00:24] To upgrade this local project to Yarn 2, I need to run yarn policies set-version berry. Yarn created this .yarn directory and this .yarnrc file. If I run yarn -v, it's also set my version to Yarn 2. The .yarnrc file sets the path to the yarn installation that we want to use.
Member comments are a way for members to communicate, interact, and ask questions about a lesson.
The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io
Be on-Topic
Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.
Avoid meta-discussion
Code Problems?
Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context
Details and Context
Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!