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 update<span 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

Canonical announces 12 year Kubernetes LTS

Canonical’s Kubernetes LTS (Long Term Support) will support FedRAMP compliance and receive at least 12…

13 hours ago

Ubuntu Weekly Newsletter Issue 878

Welcome to the Ubuntu Weekly Newsletter, Issue 878 for the week of February 2 –…

1 day ago

How your feedback shapes the way we support open source software

At Canonical, we firmly believe that delivering an outstanding, customer-centric support experience is impossible without…

2 days ago

How To Install osTicket v1.14 On Ubuntu 20.04

I want to share how to install osTicket v1.14 for Ubuntu 20.04 server. osTicket written…

3 days ago

How To Install WordPress On Ubuntu 20.04

Now I want to share how to install WordPress on ubuntu 20.04 server. WordPress is…

3 days ago

How To Install DNS Server (Bind9) On Ubuntu 20.04

Now I want to share the DNS server installation process on your Ubuntu 20.04 server.…

3 days ago