Categories: Ubuntu

How to install Yarn on Ubuntu 20.04 LTS

Yarn is an npm-compatible JavaScript package manager that automates the installation, updating, managing, and uninstalling procedure of npm packages. This application manager assists in caching every downloaded package and parallelizing processes to speed up the installation process. Whether you are a business user working on one-shot projects or a hobbyist, Yarn got you covered!

This write-up will discuss the method to install Yarn on Ubuntu 22.04. So, let’s start!

How to Install Yarn on Ubuntu 22.04

To install Yarn on Ubuntu 22.04, you must follow the below-given step-by-step instructions.

Step 1: Update system repositories
Press “CTRL+ALT+T” to open the terminal of the Ubuntu 22.04 and run the below-given command to update system repositories:

Sponsored
$ sudo apt updatespan id=“more-59779”>span>

Step 2: Install CURL on Ubuntu 22.04
After updating the Ubuntu 22.04 system repositories, execute the following command for CURL installation:

$ sudo apt install curl

The given error-free output signifies that we have successfully installed CURL on our system:

Step 3: Import Yarn GPG key
In the next step, utilize the “curl” command for importing the Yarn GPG key to Ubuntu system repositories:

$ curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add

Step 4: Enable Yarn repository
After importing the GPG key, you have to enable the Yarn repository on your Ubuntu 22.04 system. For this purpose, write out the following command in the terminal:

$ echo “deb https://dl.yarnpkg.com/debian/ stable main” | sudo tee /etc/apt/sources.list.d/yarn.list

Step 5: Install Yarn on Ubuntu 22.04
If you have carefully followed the previous steps, then at this point, your Ubuntu 22.04 system is all ready for Yarn installation. To do so, execute the below-given command:

$ sudo apt install yarn

Enter “y” to permit the installation process to continue and wait for a few minutes:

Sponsored

Step 6: Check Yarn version
To verify if Yarn is successfully installed or not, then check its installed version on your Ubuntu 22.04 system:

$ yarn –version

As you can see that currently Yarn version “0.32+git” is installed on our system:

How to upgrade Yarn on Ubuntu 22.04

Want to upgrade Yarn to the latest version? If yes, then first install “npm” on your system; if you do not have it already:

$ sudo apt install npm

Then, download the “Yarn” tarball and install its latest version by writing out the following command in the Ubuntu 22.04 terminal:

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

As you can see from the highlighted part of the below output, Yarn installed on our system is upgraded to the latest “1.22.18” version:

Lastly, execute the “yarn” command with the “–version” option to confirm that Yarn is upgraded to the latest version:

$ yarn –version

We have compiled the simplest method to install Yarn on Ubuntu 22.04. Moreover, the procedure to upgrade the current Yarn to the latest version is also provided to you.

Conclusion

To install Yarn on Ubuntu 22.04, first of all, install CURL with the “$ sudo apt install curl” command. After doing so, import the Yarn GPG key and enable its repository on your system. Then, execute the “$ sudo apt install yarn” for Yarn installation. You can also utilize the “$ sudo curl –compressed -o- -L https://yarnpkg.com/install.sh | bash” to upgrade Yarn. This write-up discussed the method to install Yarn on Ubuntu 22.04.

Ubuntu Server Admin

Recent Posts

Welcome to the Ubuntu Weekly Newsletter 883

Welcome to the Ubuntu Weekly Newsletter, Issue 883 for the week of March 9 –…

3 hours ago

How to Install nvidia-smi on Ubuntu or Debian Linux

In this article, we will see how to install nvidia-smi on Ubuntu or Debian Linux.…

15 hours ago

How to Install clang tool on Ubuntu or Debian Linux

In this article, we will see how to install clang tool on Ubuntu or Debian…

2 days ago

How to resolve Ubuntu 20.04 Container Signature Errors on Raspberry Pi ARM Devices

When working with Docker containers on Raspberry Pi devices, you might encounter frustrating signature verification…

2 days ago

How to fix DNS Resolution Issues with OpenVPN on Ubuntu 18.04

You’ve recently upgraded to Ubuntu 18.04 and found that your OpenVPN connection no longer resolves…

2 days ago

How to Fix Ubuntu 18.04 System Monitor Launch Issues

Have you ever tried to open System Monitor on your Ubuntu 18.04 system only to…

3 days ago