How do I install Yarn on Linux?

By Angus Published 15 January 2025 Updated 16 January 2025 2 min read

Yarn is an alternative JS package manager Node.js projects. It was created to solve some of the issues with npm (Node Package Manager). And, is focused on speed, security, consistency, while npm has caught up in many areas Yarn is still very popular among developers and is likely to stay around for awhile longer.

Some key features of Yarn include:

  • Caching: Yarn caches packages locally so subsequent installs are faster.
  • Deterministic Installs: Yarn ensures your dependency tree is always the same.
  • Checksum Verification: Verifies packages.
  • Workspaces: Supports monorepos, multiple projects in one repo.

First off check which version (if any) is installed, you can do this with the following command.

yarn --version

Install Yarn with npm

To use Yarn across all projects, you need to install it globally. You can do this using npm which comes with Node.js. Use the -g flag to install Yarn globally:

1. Start by installing Yarn with npm we use the command below with a -g flag to indicate it is a global install.

sudo npm install -g yarn

2. Afterwards you can verify the current Yarn version with the command shown below,

yarn –version

3. If you want to set a specific version you can use the set version command.

yarn set version "version_number"

4. Finally to revert any set version changes you can set Yarn back to the latest up to date package with the following:

yarn set version latest

Install Yarn with cURL

For systems that don’t have npm, have more stricter install requirements or simply want a bit of a shortcut we can use cURL to download and install the latest Yarn version using the command below.

curl --compressed -o- -L https://yarnpkg.com/install.sh | bash

Need more power?

Get scalable resources with our VPS hosting with root access and optional software.

Get VPS Hosting

Starting something new?

Perfect for websites and small businesses unlimited bandwidth with cPanel hosting.

Get cPanel Hosting