- Fast: Yarn caches every package it has downloaded.
- Reliable: Using a detailed but concise lockfile format and a deterministic algorithm for install operations.
- Secure: Yarn uses checksums to verify the integrity of every installed package before its code is executed.
There are also other features such as its efficiency in the use of the network as well as an offline mode. All this can be found on the Github site of Yarn.
Install Yarn on Ubuntu
The process is very simple since Yarn has a package repository at our disposal. This means that the installation can be done from the terminal and using APT. So let’s go for it.
First, open a terminal emulator. Then, add the GPG key from the repository.
:~$ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
Then, add the Yarn repository.
:~$ echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
After that, update the APT cache.
:~$ sudo apt update
If we are currently using Nodejs and NPM, we can install Yarn using the following command:
:~$ sudo apt-get install --no-install-recommends yarn
Otherwise, we will use this one.
:~$ sudo apt-get install yarn
The main difference is that NodeJS is dependent on Yarn. Then, the second command will install it from Ubuntu repositories. And the first one will leave everything as it is.
Next, check the installed version.
:~$ yarn --version
And that’s it.
Yarn is a great alternative to NPM to manage the dependencies of our web projects. So it becomes essential if we are web developers or we are learning in it.
Please share this post with your friends.