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
.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.