How to Install Yarn on Windows using several different methods
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.
1. Using the Yarn installation file [ ] from GitHub.
Download the .msi installer for Windows. Run the installer and follow the prompts.
2. Using Chocolatey
If you have Chocolatey installed, you can easily install Yarn with a single command:
Open Command Prompt as an administrator. Run the following command:
choco install yarn
3. Using npm
If you have Node.js installed, you can install Yarn globally via npm:
Open Command Prompt or PowerShell. Run the following command:
npm install --global yarn
4. Using Scoop
If you prefer using Scoop, you can install Yarn with it:
- Open PowerShell and install Scoop if you haven’t already: powershell
iwr get.scoop.sh -useb | iex
- Install Yarn
scoop install yarn
5. Using WSL (Windows Subsystem for Linux)
If you have WSL set up, you can install Yarn using a package manager like apt:
Open your WSL terminal. Run the following commands:
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn
Verification
After installation, verify that Yarn is installed by running:
yarn --version
Choose the method that best fits your setup! After following this tutorial, you should have a copy of Yarn installed and ready to use.