In this tutorial, You will learn about How to Install Yarn on Linux Ubuntu 20.04. Stay with us to verify two ways of installing Yarn on Ubuntu. But First, let’s see what is Yarn and why you need to use it. When you start a programming project, you need help to manage the dependencies correctly. Since the project libraries have a certain role in controlling the development of a project, you need to choose a suitable tool. To get familiar with Yarn, a fast and secure tool which a reliable package dependency manager for Nodejs applications, follow this guide. To start with your own Linux VPS server, count on Eldernode best services.
Table of Contents
Tutorial Install Yarn on Linux Ubuntu 20.04
Install Yarn on Linux Ubuntu 20.04 | Ubuntu 18.04
How to Install Yarn with PPA
Before the installation, import the GPG key to verify the yarn packages:
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
Then, enable the Yarn package manager repository, with type below command:
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
Then for install the yarn package manager, run the below commands :
sudo apt update && sudo apt install yarn
After installation finished, checks the installed yarn version with the below command:
How to Install Yarn with NPM
For the install Yarn package manager with npm that’s enough, run the command below:
npm install -g yarn
At this point, you have learned how to install the yarn package manager installation in 2 ways. If it works for you to continue learning the same guide on Yarn on CentOS 7 and Yarn on CentOS 8, you can find them on our blog.
Why is Yarn faster than NPM?
There is no doubt that Yarn works much more efficiently during installation. The NPM first tracks all branches of dependencies and then receives the required packages. But Yarn doesn’t. It first searches for dependencies in the registry. It then receives the downloaded packages from the cache directory. If it finds a dependency, it uses it, if not, it downloads it as tar. Finally, it copies all packets from the global cache to the node_modules directory.
All these operations are performed in parallel to increase the installation speed. Using a global cache is much faster than downloading all the packages every time we need them. Yarn also has an added advantage: it allows Yarn to work offline!
In this article, you have learned how to install Yarn on Ubuntu. Except for this ability, now you clearly know that Yarn is much better than NPM. From now on you are ready to use this tool and enjoy its features.