How to Install Yarn on Ubuntu 20.04
Yarn is the fast, reliable, and secure package management system for Nodejs application. it have multiple benefit over the npm. Yarn makes a cache for every package downloaded on your system and reuse when required again. It doesn’t need to download it again and again.
In this article, we will guide you to install Yarn with different steps on Ubuntu 20.04
Method 1 – Using the Yarn repository for Ubuntu
First, if you don’t have curl installed, you can install it from the official repositories, by running
sudo apt install curl
Import the GPG key to verify the yarn packages before the installation.
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
After running the above command if the following error occurs, you can run this command then try again
apt-get update
apt-get install gnupg
It was successful and there were no errors
Then, enable the Yarn package manager repository, type:
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
Next, run the below commands to install yarn on Ubuntu 20.04 Linux system:
sudo apt update && sudo apt install yarn
Once the installation is finished, check the installed yarn version
yarn --version
Method 2 – Install Yarn on Ubuntu 20.04 using NPM
If you are going to use Yarn, then you should already have NodeJS on Ubuntu 20.04 and npm installed.
In this sense, once they are already installed, just run this command to install Yarn.
sudo npm install --global yarn
Removing Yarn on Ubuntu 20.04
If you want to uninstall Yarn on Ubuntu 20.04 you can do it easily from the terminal.
If you installed Yarn using method 1, then you have to uninstall it by running
sudo apt remove yarn
Also, it is recommended to remove the repository from the system.
sudo rm /etc/apt/sources.list.d/yarn.list
Conclusion
Yarn is an innovative package manager that allows Javascript developers to get their work done quickly and efficiently, especially on large projects.