2. Installation

Before you start using Yarn, you'll first need to install it on your system. There are a growing number of different ways to install Yarn:

Alpine

On Alpine Linux (3.6+), you can install Yarn with apk.

apk add yarn

Currently, there are no Alpine packages available for RC or nightly builds of Yarn. Please use the tarball:

Installation Script

One of the easiest ways to install Yarn on macOS and generic Unix environments is via our shell script. You can install Yarn by running the following code in your terminal:

curl -o- -L https://yarnpkg.com/install.sh | bash
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --rc
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --nightly

The installation process includes verifying a GPG signature. View the source on GitHub

You can also specify a version by running the following code in your terminal:

curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version [version]

See the releases for possible versions.

Manual Install via tarball

You can install Yarn by downloading a tarball and extracting it anywhere.

cd /opt
wget https://yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/
cd /opt
wget https://yarnpkg.com/latest-rc.tar.gz
tar zvxf latest-rc.tar.gz
# Yarn is now in /opt/yarn-[version]/
cd /opt
wget https://nightly.yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/

Before extracting Yarn, it is recommended that you verify the tarball using GPG:

wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --import
wget https://yarnpkg.com/latest.tar.gz.asc
gpg --verify latest.tar.gz.asc
# Look for "Good signature from 'Yarn Packaging'" in the output

Path Setup

If Yarn is not found in your PATH, follow these steps to add it and allow it to be run from anywhere.

Note: your profile may be in your .profile, .bash_profile, .bashrc, .zshrc, etc.

  1. Add this to your profile: export PATH="$PATH:/opt/yarn-[version]/bin" (the path may vary depending on where you extracted Yarn to)
  2. In the terminal, log in and log out for the changes to take effect

To have access to Yarn’s executables globally, you will need to set up the PATH environment variable in your terminal. To do this, add export PATH="$PATH:`yarn global bin`" to your profile, or set PATH $PATH (yarn global bin) in the ~/.config/fish/config.fish file if you use Fish shell.

Arch Linux

On Arch Linux, Yarn can be installed through the official package manager.

pacman -S yarn

Currently, there are no Arch packages available for RC or nightly builds of Yarn. Please use the tarball:

Installation Script

One of the easiest ways to install Yarn on macOS and generic Unix environments is via our shell script. You can install Yarn by running the following code in your terminal:

curl -o- -L https://yarnpkg.com/install.sh | bash
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --rc
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --nightly

The installation process includes verifying a GPG signature. View the source on GitHub

You can also specify a version by running the following code in your terminal:

curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version [version]

See the releases for possible versions.

Manual Install via tarball

You can install Yarn by downloading a tarball and extracting it anywhere.

cd /opt
wget https://yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/
cd /opt
wget https://yarnpkg.com/latest-rc.tar.gz
tar zvxf latest-rc.tar.gz
# Yarn is now in /opt/yarn-[version]/
cd /opt
wget https://nightly.yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/

Before extracting Yarn, it is recommended that you verify the tarball using GPG:

wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --import
wget https://yarnpkg.com/latest.tar.gz.asc
gpg --verify latest.tar.gz.asc
# Look for "Good signature from 'Yarn Packaging'" in the output

Path Setup

If Yarn is not found in your PATH, follow these steps to add it and allow it to be run from anywhere.

Note: your profile may be in your .profile, .bash_profile, .bashrc, .zshrc, etc.

  1. Add this to your profile: export PATH="$PATH:/opt/yarn-[version]/bin" (the path may vary depending on where you extracted Yarn to)
  2. In the terminal, log in and log out for the changes to take effect

To have access to Yarn’s executables globally, you will need to set up the PATH environment variable in your terminal. To do this, add export PATH="$PATH:`yarn global bin`" to your profile, or set PATH $PATH (yarn global bin) in the ~/.config/fish/config.fish file if you use Fish shell.

CentOS / Fedora / RHEL

On CentOS, Fedora and RHEL, you can install Yarn via our RPM package repository.

curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo

If you do not already have Node.js installed, you should also configure the NodeSource repository:

curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -

Then you can simply:

sudo yum install yarn
## OR ##
sudo dnf install yarn

Currently, there are no RPM packages available for RC or nightly builds of Yarn. Please use the tarball:

Installation Script

One of the easiest ways to install Yarn on macOS and generic Unix environments is via our shell script. You can install Yarn by running the following code in your terminal:

curl -o- -L https://yarnpkg.com/install.sh | bash
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --rc
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --nightly

The installation process includes verifying a GPG signature. View the source on GitHub

You can also specify a version by running the following code in your terminal:

curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version [version]

See the releases for possible versions.

Manual Install via tarball

You can install Yarn by downloading a tarball and extracting it anywhere.

cd /opt
wget https://yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/
cd /opt
wget https://yarnpkg.com/latest-rc.tar.gz
tar zvxf latest-rc.tar.gz
# Yarn is now in /opt/yarn-[version]/
cd /opt
wget https://nightly.yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/

Before extracting Yarn, it is recommended that you verify the tarball using GPG:

wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --import
wget https://yarnpkg.com/latest.tar.gz.asc
gpg --verify latest.tar.gz.asc
# Look for "Good signature from 'Yarn Packaging'" in the output

Path Setup

If Yarn is not found in your PATH, follow these steps to add it and allow it to be run from anywhere.

Note: your profile may be in your .profile, .bash_profile, .bashrc, .zshrc, etc.

  1. Add this to your profile: export PATH="$PATH:/opt/yarn-[version]/bin" (the path may vary depending on where you extracted Yarn to)
  2. In the terminal, log in and log out for the changes to take effect

To have access to Yarn’s executables globally, you will need to set up the PATH environment variable in your terminal. To do this, add export PATH="$PATH:`yarn global bin`" to your profile, or set PATH $PATH (yarn global bin) in the ~/.config/fish/config.fish file if you use Fish shell.

Debian / Ubuntu

On Debian or Ubuntu Linux, you can install Yarn via our Debian package repository. You will first need to configure the 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
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ rc main" | sudo tee /etc/apt/sources.list.d/yarn.list
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://nightly.yarnpkg.com/debian/ nightly main" | sudo tee /etc/apt/sources.list.d/yarn.list

On Ubuntu 16.04 or below and Debian Stable, you will also need to configure the NodeSource repository to get a new enough version of Node.js.

Then you can simply:

sudo apt-get update && sudo apt-get install yarn

Note: Ubuntu 17.04 comes with cmdtest installed by default. If you’re getting errors from installing yarn, you may want to run sudo apt remove cmdtest first. Refer to this for more information.

If using nvm you can avoid the node installation by doing:

sudo apt-get update && sudo apt-get install --no-install-recommends yarn

Note: Due to the use of nodejs instead of node name in some distros, yarn might complain about node not being installed. A workaround for this is to add an alias in your .bashrc file, like so: alias node=nodejs. This will point yarn to whatever version of node you decide to use.

Path Setup

If Yarn is not found in your PATH, follow these steps to add it and allow it to be run from anywhere.

Note: your profile may be in your .profile, .bash_profile, .bashrc, .zshrc, etc.

  1. Add this to your profile: export PATH="$PATH:/opt/yarn-[version]/bin" (the path may vary depending on where you extracted Yarn to)
  2. In the terminal, log in and log out for the changes to take effect

To have access to Yarn’s executables globally, you will need to set up the PATH environment variable in your terminal. To do this, add export PATH="$PATH:`yarn global bin`" to your profile, or set PATH $PATH (yarn global bin) in the ~/.config/fish/config.fish file if you use Fish shell.

Gentoo Linux

On Gentoo Linux, you can install Yarn with portage.

sudo emerge --ask sys-apps/yarn

Currently, there are no Gentoo packages available for RC or nightly builds of Yarn. Please use the tarball:

Installation Script

One of the easiest ways to install Yarn on macOS and generic Unix environments is via our shell script. You can install Yarn by running the following code in your terminal:

curl -o- -L https://yarnpkg.com/install.sh | bash
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --rc
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --nightly

The installation process includes verifying a GPG signature. View the source on GitHub

You can also specify a version by running the following code in your terminal:

curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version [version]

See the releases for possible versions.

Manual Install via tarball

You can install Yarn by downloading a tarball and extracting it anywhere.

cd /opt
wget https://yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/
cd /opt
wget https://yarnpkg.com/latest-rc.tar.gz
tar zvxf latest-rc.tar.gz
# Yarn is now in /opt/yarn-[version]/
cd /opt
wget https://nightly.yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/

Before extracting Yarn, it is recommended that you verify the tarball using GPG:

wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --import
wget https://yarnpkg.com/latest.tar.gz.asc
gpg --verify latest.tar.gz.asc
# Look for "Good signature from 'Yarn Packaging'" in the output

Path Setup

If Yarn is not found in your PATH, follow these steps to add it and allow it to be run from anywhere.

Note: your profile may be in your .profile, .bash_profile, .bashrc, .zshrc, etc.

  1. Add this to your profile: export PATH="$PATH:/opt/yarn-[version]/bin" (the path may vary depending on where you extracted Yarn to)
  2. In the terminal, log in and log out for the changes to take effect

To have access to Yarn’s executables globally, you will need to set up the PATH environment variable in your terminal. To do this, add export PATH="$PATH:`yarn global bin`" to your profile, or set PATH $PATH (yarn global bin) in the ~/.config/fish/config.fish file if you use Fish shell.

macOS

Homebrew

You can install Yarn through the Homebrew package manager. This will also install Node.js if it is not already installed.

brew install yarn

If you use nvm or similar, you should ensure that your PATH lists nvm’s shims before the version of Node.js installed by Homebrew.

MacPorts

You can install Yarn through MacPorts. This will also install Node.js if it is not already installed.

sudo port install yarn

Installation Script

One of the easiest ways to install Yarn on macOS and generic Unix environments is via our shell script. You can install Yarn by running the following code in your terminal:

curl -o- -L https://yarnpkg.com/install.sh | bash
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --rc
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --nightly

The installation process includes verifying a GPG signature. View the source on GitHub

You can also specify a version by running the following code in your terminal:

curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version [version]

See the releases for possible versions.

Manual Install via tarball

You can install Yarn by downloading a tarball and extracting it anywhere.

cd /opt
wget https://yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/
cd /opt
wget https://yarnpkg.com/latest-rc.tar.gz
tar zvxf latest-rc.tar.gz
# Yarn is now in /opt/yarn-[version]/
cd /opt
wget https://nightly.yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/

Before extracting Yarn, it is recommended that you verify the tarball using GPG:

wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --import
wget https://yarnpkg.com/latest.tar.gz.asc
gpg --verify latest.tar.gz.asc
# Look for "Good signature from 'Yarn Packaging'" in the output

Currently, there are no Homebrew or MacPorts packages available for RC or nightly builds of Yarn. Please use the tarball:

Installation Script

One of the easiest ways to install Yarn on macOS and generic Unix environments is via our shell script. You can install Yarn by running the following code in your terminal:

curl -o- -L https://yarnpkg.com/install.sh | bash
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --rc
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --nightly

The installation process includes verifying a GPG signature. View the source on GitHub

You can also specify a version by running the following code in your terminal:

curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version [version]

See the releases for possible versions.

Manual Install via tarball

You can install Yarn by downloading a tarball and extracting it anywhere.

cd /opt
wget https://yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/
cd /opt
wget https://yarnpkg.com/latest-rc.tar.gz
tar zvxf latest-rc.tar.gz
# Yarn is now in /opt/yarn-[version]/
cd /opt
wget https://nightly.yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/

Before extracting Yarn, it is recommended that you verify the tarball using GPG:

wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --import
wget https://yarnpkg.com/latest.tar.gz.asc
gpg --verify latest.tar.gz.asc
# Look for "Good signature from 'Yarn Packaging'" in the output

Path Setup

If Yarn is not found in your PATH, follow these steps to add it and allow it to be run from anywhere.

Note: your profile may be in your .profile, .bash_profile, .bashrc, .zshrc, etc.

  1. Add this to your profile: export PATH="$PATH:/opt/yarn-[version]/bin" (the path may vary depending on where you extracted Yarn to)
  2. In the terminal, log in and log out for the changes to take effect

To have access to Yarn’s executables globally, you will need to set up the PATH environment variable in your terminal. To do this, add export PATH="$PATH:`yarn global bin`" to your profile, or set PATH $PATH (yarn global bin) in the ~/.config/fish/config.fish file if you use Fish shell.

Upgrade Yarn

Yarn will warn you if a new version is available. To upgrade Yarn, you can do so with Homebrew.

brew upgrade yarn

Solus

On Solus, you can install yarn via the Solus repository.

sudo eopkg install yarn

Currently, there are no Solus packages available for RC or nightly builds of Yarn. Please use the tarball:

Installation Script

One of the easiest ways to install Yarn on macOS and generic Unix environments is via our shell script. You can install Yarn by running the following code in your terminal:

curl -o- -L https://yarnpkg.com/install.sh | bash
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --rc
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --nightly

The installation process includes verifying a GPG signature. View the source on GitHub

You can also specify a version by running the following code in your terminal:

curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version [version]

See the releases for possible versions.

Manual Install via tarball

You can install Yarn by downloading a tarball and extracting it anywhere.

cd /opt
wget https://yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/
cd /opt
wget https://yarnpkg.com/latest-rc.tar.gz
tar zvxf latest-rc.tar.gz
# Yarn is now in /opt/yarn-[version]/
cd /opt
wget https://nightly.yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/

Before extracting Yarn, it is recommended that you verify the tarball using GPG:

wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --import
wget https://yarnpkg.com/latest.tar.gz.asc
gpg --verify latest.tar.gz.asc
# Look for "Good signature from 'Yarn Packaging'" in the output

Path Setup

If Yarn is not found in your PATH, follow these steps to add it and allow it to be run from anywhere.

Note: your profile may be in your .profile, .bash_profile, .bashrc, .zshrc, etc.

  1. Add this to your profile: export PATH="$PATH:/opt/yarn-[version]/bin" (the path may vary depending on where you extracted Yarn to)
  2. In the terminal, log in and log out for the changes to take effect

To have access to Yarn’s executables globally, you will need to set up the PATH environment variable in your terminal. To do this, add export PATH="$PATH:`yarn global bin`" to your profile, or set PATH $PATH (yarn global bin) in the ~/.config/fish/config.fish file if you use Fish shell.

Windows

There are three options for installing Yarn on Windows.

Download the installer

This will give you a .msi file that when run will walk you through installing Yarn on Windows.

If you use the installer you will first need to install Node.js.

Download Installer Download Installer (RC) Download Installer (Nightly)

Install via Chocolatey

Chocolatey is a package manager for Windows. You can install Chocolatey by following these instructions.

Once you have Chocolatey installed, you may install yarn by running the following code in your console:

choco install yarn

This will also ensure that you have Node.js installed.

Install via Scoop

Scoop is a command-line installer for Windows. You can install Scoop by following these instructions.

Once you have Scoop installed, you may install yarn by running the following code in your console:

scoop install yarn

If Node.js is not installed, scoop will give you a suggestion to install it. Example:

scoop install nodejs

Notice

Please whitelist your project folder and the Yarn cache directory (%LocalAppData%\Yarn) in your antivirus software, otherwise installing packages will be significantly slower as every single file will be scanned as it’s written to disk.

Alternatives

If you are using another OS or one of the other options specific to your OS will not work for you, there are a couple of alternatives. You will need to install Node.js if you don’t already have it installed.

On common Linux distributions such as Debian, Ubuntu and CentOS, it is recommended to install Yarn via our packages instead.

Installation Script

One of the easiest ways to install Yarn on macOS and generic Unix environments is via our shell script. You can install Yarn by running the following code in your terminal:

curl -o- -L https://yarnpkg.com/install.sh | bash
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --rc
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --nightly

The installation process includes verifying a GPG signature. View the source on GitHub

You can also specify a version by running the following code in your terminal:

curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version [version]

See the releases for possible versions.

Manual Install via tarball

You can install Yarn by downloading a tarball and extracting it anywhere.

cd /opt
wget https://yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/
cd /opt
wget https://yarnpkg.com/latest-rc.tar.gz
tar zvxf latest-rc.tar.gz
# Yarn is now in /opt/yarn-[version]/
cd /opt
wget https://nightly.yarnpkg.com/latest.tar.gz
tar zvxf latest.tar.gz
# Yarn is now in /opt/yarn-[version]/

Before extracting Yarn, it is recommended that you verify the tarball using GPG:

wget -qO- https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --import
wget https://yarnpkg.com/latest.tar.gz.asc
gpg --verify latest.tar.gz.asc
# Look for "Good signature from 'Yarn Packaging'" in the output

Install via npm

Note: Installation of Yarn via npm is generally not recommended. When installing Yarn with Node-based package managers, the package is not signed, and the only integrity check performed is a basic SHA1 hash, which is a security risk when installing system-wide apps.

For these reasons, it is highly recommended that you install Yarn through the installation method best suited to your operating system.

You can also install Yarn through the npm package manager if you already have it installed. If you already have Node.js installed then you should already have npm.

Once you have npm installed you can run:

npm install --global yarn
npm install --global yarn@rc

Nightly builds of Yarn are not available via npm.

Path Setup

Unix/Linux/macOS

If Yarn is not found in your PATH, follow these steps to add it and allow it to be run from anywhere.

Note: your profile may be in your .profile, .bash_profile, .bashrc, .zshrc, etc.

  1. Add this to your profile: export PATH="$PATH:/opt/yarn-[version]/bin" (the path may vary depending on where you extracted Yarn to)
  2. In the terminal, log in and log out for the changes to take effect

To have access to Yarn’s executables globally, you will need to set up the PATH environment variable in your terminal. To do this, add export PATH="$PATH:`yarn global bin`" to your profile, or set PATH $PATH (yarn global bin) in the ~/.config/fish/config.fish file if you use Fish shell.

Windows

You will need to set up the PATH environment variable in your terminal to have access to Yarn’s binaries globally.

Add set PATH=%PATH%;C:\.yarn\bin to your shell environment.

Test that Yarn is installed by running:

yarn --version

Problems? If you are unable to install Yarn with any of these installers, please search through GitHub for an existing issue or open a new one.

Search for an existing issue · Open a new issue

© 2016–present Yarn Contributors
Licensed under the BSD License.
https://yarnpkg.com/en/docs/install