How to Install Yarn: A Complete Step-by-Step Guide

Learn how to install Yarn across macOS, Windows, and Linux with clear steps, verification tips, and troubleshooting. This 2026 guide keeps you aligned with modern Node tooling.

Install Manual
Install Manual Team
·5 min read
Install Yarn - Install Manual
Photo by Dewesoftvia Pixabay
Quick AnswerSteps

You're about to install Yarn, the fast package manager for Node.js projects. Choose your platform method (npm, Homebrew, or Chocolatey) and verify the install with yarn -v. You'll set PATH if needed and learn basic commands to start using Yarn right away. This quick setup gets you running quickly and safely.

What Yarn is and why you should install it

Yarn is a package manager for JavaScript projects that helps you track dependencies, run scripts, and work with multiple packages in a single repository. The Install Manual team highlights its reliable, deterministic installs and efficient caching, which can speed up development workflows. If you’ve used npm before, you’ll notice Yarn often resolves dependencies faster and creates a more predictable install experience across machines. Yarn is available in two major lines: Yarn 1 (classic) and Yarn 2+ (Berry), each with different defaults and plugin ecosystems. For most new projects, Yarn Berry’s modern features—like workspaces and zero-install workflows—offer real productivity gains, but you can choose the version that fits your team’s needs. This guide focuses on how to install Yarn correctly on macOS, Windows, and Linux, what to verify after installation, and how to troubleshoot common issues. By installing Yarn, you gain access to consistent dependency resolution, offline caching, and streamlined workspace management that can simplify monorepos and large projects. Whether you’re a homeowner tackling a personal project or a developer contributing to a shared repository, following these steps will put Yarn in your toolkit with confidence.

Prerequisites and environment checks

Before starting, verify you have a supported environment. You’ll typically need Node.js and npm present to access the registry and run scripts. Check that your system PATH includes the directories where Node.js and npm install binaries; this ensures that yarn commands are accessible from any terminal. If you’re on macOS or Linux, you may already have npm installed via your package manager; Windows users can verify by opening PowerShell and running node -v and npm -v. Ensure you have an active internet connection for downloading the binaries and registry data. Finally, decide which installation method you’ll use (npm, Homebrew, or platform-specific installers) and prepare any platform-specific prerequisites, such as Homebrew on macOS or Chocolatey on Windows. The goal of this step is to confirm you can run command-line tools and install software on your machine.

Installation methods by platform: an overview

There isn’t a single universal installer for Yarn; instead, you can choose one of several reliable paths depending on your operating system and preferences. The most common methods are: using npm to install Yarn globally, using a macOS package manager like Homebrew, or using a Windows package manager like Chocolatey. Linux users can install Yarn via their distro’s package manager (apt, dnf, or pacman) or via npm if preferred. Each method results in a usable Yarn binary and a path that your shell can access. We’ll cover each approach briefly in this section, then dive into step-by-step instructions for the platform-specific methods in the next section. If you already have Node.js installed, the npm method becomes particularly convenient because Yarn can be installed with a single command; vice versa, using corepack is another modern option when your Node environment supports it. Remember to verify the installation after completing any method.

Installing Yarn on macOS, Windows, and Linux: step-by-step by platform

  • macOS (Homebrew): If you use Homebrew, installing Yarn is straightforward. First, ensure Homebrew is up to date with brew update. Then run brew install yarn. If you want to avoid installing Node with Homebrew, you can install Yarn with the --ignore-dependencies flag or use corepack to manage Yarn versions. After installation, run yarn -v to confirm the version and path.
  • Windows (Chocolatey): With Chocolatey, open an elevated PowerShell session and run choco install yarn. This method places Yarn’s binaries on your system path. After installation, restart your terminal and run yarn -v. If you encounter permission prompts, ensure you opened PowerShell as Administrator.
  • Linux (apt/dnf/pacman): On Debian/Ubuntu, you can set up the official Yarn repository or install via npm. For Red Hat-based distributions, use dnf or yum with the Yarn repository. After installing, verify with yarn -v and test a simple command like yarn init to ensure it works as expected. The Linux instructions assume you have a functioning package manager and network access.

Tools & Materials

  • Node.js (runtime)(Install from nodejs.org; includes npm)
  • Homebrew (macOS)(Optional if you plan to use the macOS method)
  • Chocolatey (Windows)(Optional if you plan to use the Windows method)
  • Internet access(Needed to fetch binaries and registry data)
  • Terminal/PowerShell(Access to a command-line interface)
  • Corepack (optional)(If you want to manage Yarn versions via Corepack)

Steps

Estimated time: 15-25 minutes

  1. 1

    Check prerequisites

    Open a terminal and verify Node.js and npm are installed. Run node -v and npm -v to confirm versions. This ensures you can run the Yarn installer and that Node tooling is ready for dependency management.

    Tip: If Node.js is missing, install it from nodejs.org before continuing.
  2. 2

    Choose installation method

    Decide which method to use based on your OS and preferences: npm globally, Homebrew on macOS, or Chocolatey on Windows. Each path makes Yarn available on your PATH so you can run yarn commands in any shell.

    Tip: For cross-machine consistency, consider using a version manager or Corepack.
  3. 3

    Install Yarn via npm

    Run npm i -g yarn to install Yarn globally. This makes the yarn command accessible to all shells and projects on the machine.

    Tip: Prefer a non-root user when installing global packages; use sudo only if required by your environment.
  4. 4

    Install Yarn with macOS Homebrew

    If you’re on macOS with Homebrew, update Homebrew and install Yarn using brew update then brew install yarn. After installation, verify with yarn -v.

    Tip: If you already installed Node via Homebrew, Yarn version management is streamlined.
  5. 5

    Install Yarn with Windows Chocolatey

    On Windows, perform choco install yarn in an elevated PowerShell session. Restart the terminal and run yarn -v to verify.

    Tip: If you’re behind a proxy, configure npm and Chocolatey to use the proxy first.
  6. 6

    Optional: manage Yarn versions

    Consider enabling Corepack or a version manager to stabilize Yarn versions across projects and machines.

    Tip: Corepack can help keep Yarn in sync with your Node tooling; check Yarn docs for commands.
Pro Tip: Use a single installation method per machine to minimize PATH conflicts.
Warning: Avoid running global installs as the default user if your system permissions are tight.
Note: If you already use npm, you can install Yarn with a single command without changing project configs.
Pro Tip: Document the exact install method in your project README to aid future contributors.

Got Questions?

What is Yarn and why should I install it?

Yarn is a package manager for JavaScript that helps manage dependencies and scripts efficiently. It provides deterministic installs and a robust cache, which can speed up project setup and improve reproducibility.

Yarn helps you manage dependencies reliably and quickly; it’s a solid choice for JavaScript projects.

Do I need Node.js before installing Yarn?

Yes. Yarn relies on Node.js to run and to access the package registry. Install Node.js (which includes npm) before installing Yarn to ensure a smooth setup.

Node.js is required for Yarn to run, so install Node.js first.

Which installation method should I use?

The best method depends on your OS and workflow. npm is universal, Homebrew is convenient on macOS, and Chocolatey is common on Windows. Pick one method and stay consistent across machines in your team.

Choose a method that fits your system and stick with it for consistency.

How do I update Yarn after installation?

You can update Yarn by using the same installation method you used initially or by using Corepack if you rely on it for version management. Check the official Yarn docs for the exact commands.

Update Yarn with your chosen method or Corepack, following the official guide.

What if Yarn isn’t recognized after installation?

If yarn isn’t recognized, check your PATH to ensure the Yarn binary directory is included. Reopen your terminal and verify the installation step you followed. Reinstall if necessary.

Make sure Yarn is on your PATH, then try again.

Watch Video

Main Points

  • Verify Node.js and npm exist before installing Yarn
  • Choose a platform-appropriate installation method
  • Always verify installation with yarn -v
  • Consider Corepack to stabilize Yarn versions
  • Document your installation method for teammates
Process diagram showing Yarn installation steps across platforms

Related Articles