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.
Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform Software Installation tasks on Ubuntu Linux Systems.
In this context, we shall look into how you can install Yarn on Ubuntu Linux system.
To begin, log in as root or should have the privileged to run sudo commands.
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.
Curl can be installed from the official Ubuntu packages repository.
To install Curl, Run the following 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.
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
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
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 will be displayed on the terminal window.
This verifies that the Yarn is installed on this system.
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
This article covers how to install Yarn on Ubuntu 20.04 LTS system. Yarn is a JavaScript package manager compatible with npm that helps you automate the process of installing, updating, configuring, and removing npm packages.
It caches every download package and speeds up the installation process by parallelizing operations.
To Yarn on Ubuntu Linux:
1. Import the repository’s GPG key and add the Yarn APT repository to your system by running the following commands:
$ 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
2. Once the repository is enabled, update the package list, and install Yarn:
$ sudo apt update
$ sudo apt install yarn
3. If you installed Node trough nvm, skip the Node.js installation with:
$ sudo apt install --no-install-recommends yarn
4. Once completed, verify the installation by printing the Yarn version:
$ yarn --version