How to install Yarn on Ubuntu 20.04

Yarn is a JavaScript dependency manager that automates tasks related to managing npm packages, including installation, downloading updates, and scheduling configuration. Yarn saves you from downloading each package again, as it caches each one. This means that a JavaScript programmer can save a lot of time by shifting these routine tasks to yarn.

Yarn is a reliable, well-maintained, and proven utility that will work wonders in managing software on your system.

This article will show you how to get yarn working on your Ubuntu 20.04 system. Read carefully and follow the instructions below.

Step 1: Install Yarn’s Package Repository

Before installing Yarn, you must add the Yarn ATP repository on your system.

First, make sure the packages are from the official sources by adding the repository’s GPG key. Enter the following commands to add the Yarn repository’s GPG key to your system.

To add the yarn repository with the GPG key, start a terminal and enter the following commands:

$ sudo apt update

$ sudo suitable To install Beckon

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

Then enter the following to add the repository:

$ echo “deb https://dl.yarnpkg.com/debian/stable main” |
sudo tea /Etc/suitable/Sources.list.d/Yarn list

The system is now ready to add yarn to its active programs.

Step 2: Install Yarn on your Ubuntu 20.04 system

After completing the above step, you can now proceed to install Yarn. Check if you have Node.js on your system. If Node.js is pre-installed, you can custom install yarn by running the following command:

$ sudo suitable To install –no-install-recommended yarn

Otherwise, if Node.js is not pre-installed, you will need to download the Node.js dependencies with Yarn.

$ sudo apt update && Update

$ sudo suitable To install yarn

Here’s how you can install Yarn on your Ubuntu 20.04 computer.

Step 3: check the installation

With Yarn now installed on your system, all you have to do is check that the installation was up to date. Enter the following commands to start the installation.

$ yarn -Execution

This should print out the version of yarn your system has, display the number, and thereby verify the installation.

We’re now going to look at some of the basics to get you started with yarn.

Step 4: getting started with yarn

After you finish the installation, it is time to familiarize yourself with some of the basic commands used in Yarn.

Some of the commands you will frequently need when using yarn include the following.

Start a new project

Enter the following command to create a directory for your new project:

$ mkdir ~/My project && CD ~/My project

Then build your project with the following line:

$ Yarn init my_project

You will be asked for the specifications of your project, which you can answer yourself, or simply use the standard values.

The script creates your project’s package.json file to get you started.

Add and update dependencies

You can attach an npm package to a file you’ve created using the following command:

To add an npm package to the project dependencies, use the yarn add command followed by the package name:

$ Add yarn [package_name]

This should update your package.json file. Note that if you just add the package name, Yarn will install the latest version. Enter the code below to upgrade to a version of your choice.

$ Add yarn [package_name]@[version_or_tag]

Remove a dependency

You can also remove a dependency. Enter the following command:

$ Remove yarn [package_name]

Notice that your project’s package.json and Garn.lock files are also updated.

Automate the installation of all dependencies

You can also automate the installation of all project dependencies contained in your package.json project file. To do this, enter the following command:

$ yarn To install

Wrap up

This article describes how to install Yarn on the latest Ubuntu version from April 20th. The article also covers creating new project files and updating them and their dependencies.

With Yarn installed on your system, you can use the Yarn APT repository to manage npm packages very efficiently. Yarn records which version update worked on which systems and works out the optimal solution for upgrading your dependencies. The official repository for Yarn is regularly updated and maintained to give you the latest versions of the software you download.

To learn more about Yarn, visit the official website.

Related Posts