This guide will demonstrate the approach for installing Yarn on Windows.
Prerequisite: Install Node.js
The Yarn package manager can be installable using NPM (Node package manager) or corepack manager. For this purpose, we need to install Node.js first on Windows as npm and corepack are installed automatically with Node.js components. For Node.js installation on Windows, follow the provided steps:
Step 1: Download the Node.js Setup file
Open the below-provided link and download the latest version of the Node.js installer along with corepack and npm package manager:
Step 2: Run Node.js Setup File
By default, the setup file is downloaded in the Downloads folder. Open the Downloads folder and execute the Node.js installer to install Node.js. To do this, double-click the Node.js setup file:
On the screen, the “Node.js Setup” wizard will appear. To begin installing Node.js, click “Next“:
Mark the Node.js License Agreement as accepted and press the “Next” button:
Provide the address of the location where Node.js will be installed. After that, hit the “Next” button:
You can see that with the Node.js installation, we automatically got corepack and npm package manager. Press the “Next” button to proceed further:
We do not need any other package for yarn installation, therefore, unmark the checkbox and press the “Next” button:
To start the installation of Node.js, click the “Install” button:
Node.js is installed successfully and we are all set to install Yarn on windows.
How to Install Yarn Using Command Prompt on Windows?
Step 1: Open Command Prompt
First, type “cmd” in the “Start” menu, and open Command Prompt as admin from display results:
Step 2: Enable Corepack
In the first section, we have installed corepack with Node.js installation. We need to enable it only. For this purpose, execute the provided command. Yarn is already built into the corepack or is automatically included:
Alternatively, we can utilize npm package manager to install yarn individually:
Note: Corepack is not supported in Node.js versions 15 and below. In order to manually add Corepack, use the provided command:
Step 3: Verify Yarn Installation
To ensure Yarn’s installation on Windows, check its version:
Step 4: Update Yarn Version
We can update Yarn to the latest version to enjoy yarn’s newer features using provided command:
The above-provided command updates the Yarn to stable Yarn version.
Step 5: Verify Yarn Version Updation
Again, check out the Yarn version to confirm that yarn is updated or not:
Now, you can see that we have successfully updated the yarn version:
After updating, it is observed that the yarn version has been changed from “1.22.19” to “3.2.2”. That’s it! We have the latest recent installation of yarn on Windows.
How to Install Yarn Using PowerShell on Windows?
PowerShell is a command line user interface of Windows. In PowerShell, we can install and use the Chocolatey package manager for Yarn installation. For this purpose, the method outlined below is sufficient.
Step 1: Open PowerShell
Open the Window Start menu and search “PowerShell” to open Windows PowerShell as an admin:
Step 2: Install Chocolatey
First, use the command supplied below to install the Chocolatey package manager:
The output indicates that we have successfully installed Chocolatey:
Step 3: Confirm Chocolatey Installation
Use the “choco” command to validate the installation of Chocolatey by executing the “choco” command:
You can see that we have installed “Chocolatey v1.1.0” on Windows from the results shown below:
Step 4: Install Yarn
Utilize the Chocolatey package manager to Yarn on Windows. To do this, execute the below command:
From the output given below, you can see we have successfully installed Yarn on Windows:
We have compiled the procedure for installing Yarn on Windows.
To install the Yarn package manager on Windows, you can either use npm or Chocolatey package manager to use npm to install yarn, it is required to install Nodejs first. Because Node.js included npm and corepack which enable us to install and use a yarn package manager. We can install yarn by enabling the “corepack” manager or utilize the npm package manager to install yarn individually. In the second approach, you can install and use Chocolatey on PowerShell to install Yarn. In this blog, we have offered the simplest method to install Yarn on Windows.