Struggling to install Yarn on your Ubuntu, Debian, or LinuxMint system? Don’t worry! With these three simple methods, you’ll be able to install Yarn in no time. Yarn is a powerful package manager that allows you to install, update, and uninstall applications with ease. It also helps you manage multiple versions of libraries and applications, so you can easily switch between them. With these three methods, you can easily install Yarn on your Ubuntu, Debian, or LinuxMint system and get started with your projects! So why wait? Let’s dive in and explore the three methods to install Yarn.
In this article:
- Installing yarn package manager using NPM
- Install yarn using official shell script
- Install yarn using official PPA
You can choose any of the 3 methods to install yarn package manager on your system.
Method 1: Install Yarn using NPM
The yarn package is available to install with NPM. You can simply use the npm command as follows to install Yarn globally. To install yarn for the current project only just remove the -g option from the command.
sudo npm install yarn -g
Check the installed version:
Method 2: Install Yarn using Shell Script
Yarn also provides a shell script for installation. This is the most recommended way to install Yarn on a Linux system. This script downloads the yarn archive and extracts it under the .yarn directory under your home directory. Also, set the PATH environment variable.
curl -o- -L https://yarnpkg.com/install.sh | bash
As this installation put all files under the user’s home directory, So it is available for the current users only.
Method 3: Install Yarn using PPA
The Yarn team also provides an Apt repository to install yarn on a Debian machine. Run the following commands to import gpg key and configure yarn apt 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
Ubuntu 22.04 and Debian 11 or the newer versions, use the following commands to configure the repository:
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
Now type the following commands to install yarn on Ubuntu Debian and Linux.
sudo apt-get update && sudo apt-get install yarn
This will complete the Yarn installation on your system.
In this blog post, you have learned 3 methods of installing the yarn package manager on Ubuntu, Debian, or Linux Mint systems. You can choose any of the three methods to install yarn on Linux system.