Project dependencies management is an essential task in almost all kinds of programming applications. Different tools are used to manage the project libraries during the application development. Yarn is an open-source, secure, fast, and reliable package manager for all types of NodeJs applications with providing various benefits and best choices over the NPM. Yarn keeps the cache of the downloaded package on your system, and however, if you need it then you can reuse this package without again wasting time in downloading the required package. It verifies the integrity through checksums of each installed package before running its complete code. One more important feature of yarn is its efficiency in the network mode as well as in offline network mode.
This article will provide details about how you can install Yarn on the Linux system. All steps we have executed on the Ubuntu 20.04 system.
You should log in as root or should have the privileged to run sudo commands.
Yarn Installation on Ubuntu 20.04
Yarn can install on your machine from its official repository that is available on Ubuntu 20.04 LTS system. Using the PPA method, yarn can install globally on the system. So that, each system user can use this application.
First, open the terminal using the keyboard shortcut by pressing ‘Ctrl +Alt + t’. Then, follow the following steps to install Yarn:
Step 1: Install Curl Command-line Utility
Curl can be installed from the official Ubuntu packages repository. For Curl installation, Type the below-mentioned command in the terminal:
$ sudo apt install curl
When install curl, it notifies the user that extra system space is needed to complete this operation. Press ‘y’ from the keyboard and then hit ‘Enter’ to proceed further.
Step 2: Add and enable Yarn Repository
Installation of Yarn is a simple and straightforward procedure. First, download and import the GPG key. Add the yarn repository and enable it. The yarn repository is maintained consistently and provides an up to date yarn version.
Run the following command to import the Yarn repository’s GPG key and add the Yarn apt repository to your system.
$ 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
Step 3: Install Yarn
Once the yarn repository is enabled, update the apt-cache, and by running the following command install Yarn on Ubuntu 20.04 system:
$ sudo apt update
$ sudo apt install yarn
The above command will also install NodeJs packages on your system. If you have already complete the NodeJs installation through nvm on your system then, skip the installation of NodeJs with the following command:
$ sudo apt install --no-install-recommends yarn
Step 4: Check the Yarn version
Once the yarn installation is completed, check the installed Yarn version on your system. In this way, you can easily verify that either it is successfully installed on your system or not. Therefore, use the following command to check the installed Yarn version:
$ yarn --version
The installed version is displayed on the terminal window that verifies that the Yarn is installed on this system.
Remove or Uninstall Yarn
Sometimes, you need extra space to install more useful applications. So, if you don’t need the Yarn application any more then, uninstall it by executing the following command:
$ sudo apt remove yarn
We have discussed in this article how to install Yarn on Ubuntu 20.04 LTS system. Yarn is a good choice over the NPM that manages the web project dependencies. So, if you are a professional programmer or learner, it is an essential part you must know about this tool. Share your reviews with us about this article through your comments.