How do I install Yarn on Linux?

By Angus Published 15 January 2025 Updated 27 January 2026 2 min read

Yarn is an alternative JavaScript package manager for Node.js projects. It was created to solve some of the issues with npm (Node Package Manager), focusing on speed, security, and consistency. Whilst npm has caught up in many areas, Yarn remains popular among developers and is likely to stick around for a good while yet.

If you’re working with Node.js applications, such as when you install MERN stack on AlmaLinux, Yarn provides a solid alternative for managing your packages.

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.

Before you start

Installing Yarn is part of managing your VPS effectively. Before installing, check if Yarn is already installed and which version you’re running:

yarn --version

If Yarn isn’t installed, you’ll see a “command not found” error. If you’re not sure which Linux distribution you’re running, you can check your Ubuntu version (or equivalent for your distribution) first.

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