How to Install Yarn on Ubuntu 22.04

Yarn is a free to use and open source software, which functions as a package manager that is used to automate the processes like installing, uninstalling, updating and managing the NPM packages. Yarn was introduced to the global market by the Google, Exponents and Tilde collaboration. Yarn gives us more relief by offering us features like security, consistency, efficiency and reliability, which makes it better than its competitors. NPM client is also a package manager that specifically manages the dependencies of JavaScript.

In this detailed guide you will learn to install Yarn on Ubuntu 22.04 LTS

How to Install Yarn on Ubuntu 22.04 LTS?

In order to install Yarn on Ubuntu 22.04 LTS, you need to follow the steps listed below there.

Step 1: Update System Packages

In order to install Yarn on Ubuntu 22.04 LTS, you first need to update system packages by the utilization of the code snippet below:

sudo apt update

Update of the system packages is achieved.

Step 2: Install curl

Now, install curl, it is a tool utilized by developers to transfer the data to and from a server:

sudo apt install curl

The cURL installation is done and completed.

To read more Ubuntu articles, click here.

Step 3: Import GPG Key

Furthermore import GPG key by the use of the command below:

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

The importing of the GPG key is completed.

Step 4: Add Yarn Repository

Add repository of yarn to the system by the use of code snippet below:

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

Adding of the Yarn repository is done.

Step 5: Install Yarn

Finally all steps are done, now we can proceed towards installation of the Yarn on Ubuntu 22.04 LTS:

sudo apt install yarn -y

The installation of the Yarn on Ubuntu 22.04 LTS is completed

Step 6: Confirm Yarn Version

Now, you can verify the Yarn installation on Ubuntu 22.04 by checking the version of Yarn by the use of the following command line:

yarn –version

The output is clearly showing the version of Yarn.

How to Update Yarn on Ubuntu 22.04?

In order to update Yarn to its latest version you need to follow the steps mentioned in the below process.

Step 1: Install NPM Package

You can install the NPM package on Ubuntu by the execution of the below command:

sudo apt install npm -y

The NPM is installed on Ubuntu 22.04 LTS.

Step 2: Install Yarn

Install the latest of Yarn on Ubuntu 22.04 LTS by the usage of the command written below:

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

Conclusion

Yarn is a package manager used to manage the NPM packages. In this guided article you have learned to install Yarn on Ubuntu 22.04 LTS. We have tried to cover this topic to give a better understanding of it.