How to Install Yarn: Step-by-Step Guide for Windows, macOS, and Linux

Before you start using Yarn, you need to install it on your system. The installation process is straightforward and works across different operating systems. In this guide, we’ll walk you through how to install Yarn on Windows, macOS, and Linux, with examples.
1. Install Yarn on Windows
Method 1: Using the Installer (Recommended)
-
Go to the official Yarn website: https://yarnpkg.com.
-
Download the Windows Installer (.msi).
-
Run the installer and follow the setup wizard.
-
Once installed, open Command Prompt or PowerShell and type:
yarn --version
If you see a version number (e.g., 1.22.19
), Yarn is installed successfully.
Method 2: Using Chocolatey (For Advanced Users)
If you already use Chocolatey, run:
choco install yarn
This automatically installs Yarn and its dependencies.
2. Install Yarn on macOS
Method 1: Using Homebrew (Recommended)
If you have Homebrew installed, simply run:
brew install yarn
This installs Yarn without Node.js (if Node.js is already installed).
If you want Yarn with Node.js:
brew install yarn --without-node
Method 2: Using npm
If you already have npm installed, you can install Yarn globally:
npm install --global yarn
Verify Installation
Run:
yarn --version
3. Install Yarn on Linux
Method 1: Using the Official Repository
Ubuntu / Debian
-
Configure the Yarn repository:
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
-
Update and install Yarn:
sudo apt update && sudo apt install yarn
If Node.js is not installed, install it first:
sudo apt install nodejs npm
Fedora / CentOS / RHEL
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
sudo yum install yarn
Method 2: Using npm
If npm is available, install Yarn globally:
npm install --global yarn
4. Verify Yarn Installation
After installation (Windows, macOS, or Linux), run:
yarn --version
If you see a version number, Yarn is ready to use.
Example: Create a New Project with Yarn
Now that Yarn is installed, let’s create a simple React app:
yarn create react-app myApp
cd myApp
yarn start
This sets up a new React project and starts the development server.
Conclusion
Installing Yarn is simple and works across all major operating systems. Whether you’re on Windows, macOS, or Linux, you can set up Yarn quickly and start managing dependencies with ease.
With Yarn installed, you’re ready to:
-
Manage dependencies faster
-
Work offline with cached packages
-
Use Workspaces for monorepos
-
Enjoy secure, deterministic builds
Now that you know how to install Yarn, the next step is to explore its commands and real-world use cases to make your JavaScript projects more efficient.