11 C
Texas
angeloma
Senior Writer and partner

How to install Yarn on Ubuntu 18.04 / Ubuntu 19.04?

The management of dependencies in a programming project is vital. That is, with certain tools we can control everything related to the project libraries. Especially in web applications where a lot of libraries and components are required for a site or web application to be modern and functional. For example, a modern website needs Javascript libraries to make it functional and didactic to the user. If there is a tool that helps us with this, everything becomes problems. Therefore, in this post, I will teach you how to install Yarn on Ubuntu 18.04 or Ubuntu 19.04.

Yarn is a Javascript dependency manager that stands out for being fast, secure and reliable. It is presented to us as the most solid alternative to NPM. In addition, it is open source and it has the protection of a giant like Facebook what guarantees us solidity and robustness of the project. Some of its characteristics are the following:

  • 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.

- Advertisement -

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

1.- Adding the Yarn repository
1.- Adding the Yarn repository

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

2.- Install Yarn on Ubuntu
2.- Install Yarn on Ubuntu

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

3.- Yarn version
3.- Yarn version

And that’s it.

Conclusion

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.

 

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article