Yarn represents a Javascript dependency manager which makes functions regarding managing npm packages inclusive of downloading and installing updates and time bound configuration to get automatized. Thus it spares the requirement of re-downloading the packages since it caches all of them. Thus, assigning routine chores to Yarn, a lot of time can be spared by Javascript programmer.
It is a sort of efficient and established manager that regulates software on system.
This abstract directs you how to install and run Yarn on Ubuntu 20.04 as to reap its benefits. The following directions should be observed.
Step 1: Installing Yarn Package Repository
Yarn ATP repository must be added to your system prior to actually installing Yarn.
Addition of the GPG key of the repository is useful to confirm that the packages are received from official website. In order to add the GPG key for the required repository, the command below is entered:
$ sudo apt update

$ sudo apt install curl

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

Now addition to the repository requires the following command:
$ echo “deb https://dl.yarnpkg.com/debian/ stable main” |
sudo tee /etc/apt/sources.list.d/yarn.list

The system is prepared to now to include Yarn to programs.
Step 2: Installing Yarn on Ubuntu20.04
After completion of the above step, you can proceed to install Yarn on the system.
If Note.js, a preliminary for Yarn, is already installed on your system, yarn can be cutom installed using this command:
$ sudo apt install –no-install-recommends yarn

If Note.js is not installed on your system then the Note.js dependencies must be downloaded with Yarn.
$ sudo apt update && upgrade

$ sudo apt install yarn

Step 3: Verification
In order to verify that the version is recent one, the command below is utilized:
$ yarn –version

This command prints the version present in the system and thus depicts the number and the install is verified.
Now we shall take you through Yarn operation.
Step 4: Start up With Yarn
Getting yourself used to with commands applied in Yarn after its installation.
Commonly used commands on Yarn that you will need are below.
Beginning a new project
The command below is used to make a directory for a new project you wish to begin:
$ mkdir ~/my_project && cd ~/my_project

You can make project by entering the command below:
$ yarn init my_project

Queries about different features of the project will be displayed on the screen which can be specified by you or default values can be used instead.
The package.json file thus created for the project will give you a start for the project.

Addition and Up gradation of Dependencies
Firstly an npm package must be adjoined to the file created.
The Yarn add command is of value in order to add npm package to project dependencies as under:
$ yarn add [package_name]

Thus package.json file is updated. By default, the latest version is installed by Yarn if package name is added only. Updating to a version of your interest requires the command below:
$ yarn add [package_name]@[version_or_tag]

Erasing a Dependency
A certain dependency can be omitted using the following command:
$ yarn remove [package_name]

This will automatically update package.json and yarn.lock files of the project also.
Automating All Dependencies’ Installation
Installation of all project dependencies files included in packages.json project can be automated by help of the command below:
$ yarn install

Conclusion
This account sums up the installation of Yarn on Ubuntu20.04 and also making new project files and keeping their up-to-date dependencies.
The npm packages can be systematically manages with Yarn ATP repository.
Version update record and dependency upgrade is well maintained by Yarn.
In order to provide you with the newer version of the software, yarn official repository is well-kept and constantly updated. You can consult their official webpage for further information.
Author Info
My name is Akhunzada Younis Said. I am a software project manager in HAZTECH, a software engineering graduate and a content writer. I love working with Linux, Data science and open-source software.