How to Install Yarn on Ubuntu 22.04


Yarn is an open-source and freely available package manager that is used to manage JavaScript runtime environments. It provides an efficient package management experience. It simplifies the process of installing, updating, managing, and uninstalling npm packages through automation. With advanced features such as package caching and parallel processing, Yarn significantly speeds up the installation process.

This write-up demonstrates the complete process of installing Yarn on Ubuntu 22.04.

How to Install Yarn on Ubuntu 22.04?

Check out the below-provided steps for installing Yarn on Ubuntu 22.04.

Step 1: Updating System Packages

Open the “Terminal” and type the following command, and hit the Enter button to update system packages on Ubuntu 22.04:

sudo apt update

Step 2: Verifying CURL Installation Status

Once you have successfully updated the repositories on your Ubuntu 22.04 system, run the following command to check the existence of CURL on Ubuntu 22.04:

curl --version

The output shows that a latest version of curl is already installed on our system:

In case curl is not installed on your system, then you can install it by executing the below-provided command:

sudo apt install curl

Step 3: Importing Yarn GPG Key

The next step is to import the Yarn GPG key on your Ubuntu 22.04 machine. For this purpose, utilize the below-given “curl” command:

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

The following snippet depicts that the Yarn GPG key has been successfully imported:

Step 4: Enabling Yarn Repository

After successfully importing the GPG key, activate the Yarn repository on your Ubuntu 22.04 machine by executing the below-provided command:

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

Step 5: Installing Yarn

Now, simply run the provided command to proceed with the installation of “Yarn” package manager:

sudo apt install yarn

The error-free output confirms the successful installation of the “Yarn” on Ubuntu 22.04:

Step 6: Verifying Yarn Installation Status

To confirm the successful installation of Yarn on your Ubuntu 22.04 system, check the installed version by running the below-provided command:

yarn --version

The output demonstrates that our Ubuntu machine has the Yarn version “0.32+git” installed.

How to Upgrade Yarn on Ubuntu 22.04?

If you want to upgrade Yarn to the latest version, make sure you have “npm” installed on your ubuntu 22.04.

To install npm, use the following command:

sudo apt install npm

The installation process will take a few minutes to complete:

After that, you can download and install the latest version of Yarn by executing the below-provided command:

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

The following snippet proves that the “Yarn 1.22.19” has been successfully installed on Ubuntu 22.04:

That’s all about installing Yarn on Ubuntu 22.04.

Conclusion

To Install Yarn on Ubuntu 22.04, first, update the system packages, install curl, import Yarn GPG key using curl, enable Yarn repository, and install Yarn by executing “sudo apt install yarn” command. Users can verify the yarn installation status by executing the “yarn –version” command. This post has illustrated step-by-step guidelines to install Yarn on Ubuntu 22.04.

Print Friendly, PDF & Email
Categories
Tags