1×
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.

Autoplay

    Install Yarn 2

    Ian JonesIan Jones
    yarnYarn

    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.

    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Discuss

    Discuss

    Transcript

    Transcript

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

    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.