How to Install Yarn on Windows

October 14, 2021

Introduction

Yarn is a package manager developed by Facebook as an alternative to the NPM client. It allows teams to develop JavaScript code and share it through software packages.

Yarn brings a host of improvements compared to NPM, such as higher speed, reliability, and greater compatibility. There are several methods of installing Yarn, from using the MSI installation file to using other package managers and installing it from the Windows PowerShell.

In this tutorial, we will offer a step-by-step process for different methods of installing Yarn on Windows.

How to install Yarn on Windows

Prerequisites

Note: Bare Metal Cloud was build by a DevOps team for DevOps teams. It supports IaC tools and automated server provisioning via API and CLI. Launch a Windows-powered Bare Metal Cloud server and follow this guide to configure Yarn on it.

Get a development sandbox environment for as low as $0.10/hour!

Install Yarn on Windows via MSI Installer

1. Download the Yarn installation file from GitHub.

2. Run the installation file and click Next to proceed.

Start the Yarn installation using the MSI installer

3. Check the box to accept the license agreement and click Next to continue.

Accept the license agreement

4. Select the destination where you want to install Yarn and click Next to proceed.

Select the install destination

5. Click Install to start the installation process.

Start the installation process

6. Once the installation is complete, click Finish to exit the installation wizard.

Click the finish button to exit the Yarn installation

7. Run the following command in the PowerShell to verify the installation:

yarn --version
Verify the installation in the PowerShell

Install Yarn on Windows via Chocolatey Package Manager

Another method is to use the Chocolatey package manager to install Yarn. Using Chocolatey also helps resolve dependencies since it automatically installs Node.js:

1. Open the PowerShell as an administrator.

2. Check the status of the execution policy with:

Get-ExecutionPolicy
Check the status of the execution policy

3. If the execution policy status is Restricted, set it to AllSigned using:

Set-ExecutionPolicy AllSigned

4. When prompted, type Y and press Enter to confirm.

Set the execution policy to AllSigned

5. Install the Chocolatey package manager by using:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

6. Run the following command to install Yarn:

choco install yarn
Install Yarn using Chocolatey

7. Type Y and press Enter when prompted to confirm the install.

8. Restart the PowerShell for the changes to take effect. Verify the installation with:

yarn --version
Verify the installation

Install Yarn on Windows via Scoop CLI

The Scoop CLI (command line installer) works in a similar way to Chocolatey, with the main difference being that Scoop does not automatically install Node.js.

1. Open the PowerShell as an administrator.

2. Set the execution policy to allow PowerShell to run local scripts:

set-executionpolicy remotesigned -scope currentuser

3. When prompted, type Y and press Enter to confirm.

Set the execution policy

4. Install Scoop CLI by using:

iwr -useb get.scoop.sh | iex
Install Scoop CLI in the PowerShell

5. Start the Yarn installation with:

scoop install yarn
Install Yarn using Scoop CLI

6. Verify the installation using:

yarn --version
Verify the installation

Install Yarn on Windows via NPM

NPM (Node Package Manager) is a package manager included with the Node.js installation. It is used for developing and sharing JavaScript code, but it also provides another method of installing Yarn:

1. Open the PowerShell as an administrator.

2. Install Yarn by running the following command:

npm install --global yarn
Install Yarn using NPM

3. Verify the Yarn installation with:

yarn --version
Verify the installation

Conclusion

After following this tutorial, you should have a copy of Yarn installed and ready to use.

If you are interested in using Yarn on a Linux system, check out our guide to installing Yarn on Ubuntu 18.04.

Was this article helpful?
YesNo
Aleksandar Kovačević
With a background in both design and writing, Aleksandar Kovacevic aims to bring a fresh perspective to writing for IT, making complicated concepts easy to understand and approach.
Next you should read
How to Install Helm on Ubuntu, Mac and Windows
December 10, 2020

Helm is a package manager for Kubernetes that simplifies deployment process. Follow this step-by-step tutorial to learn how to install Helm on Ubuntu, Mac and Windows.
Read more
How to Install Ruby on Windows 10
July 29, 2020

Ruby is often used in web applications, games, and simple scripts. Follow this simple tutorial and install Ruby on your Windows 10 by using the RubyInstaller Tool or with the Linux Subsystem.
Read more
How to Install and Use Git on Windows
January 8, 2020

Git tracks source code changes during the software development process. This tutorial uses multiple images to show you how to install Git on Windows in a few simple steps.
Read more
How To Install Python 3 on Windows 10
April 2, 2019

Unlike most Linux distributions, Windows does not come with the Python programming language by default. However, you can install Python on your Windows server or local machine in just a few simple steps.
Read more