How to Install Yarn on Debian 10

Yarn is a JavaScript package manager developed by Facebook that provides a list of benefits over its counterpart NPM. Some of these include: Faster rate of package downloads, ability to download offline packages and auto-generation of lock files. In this brief tutorial, we will give you an overview of how to install and use Yarn on Debian 10.

Let’s begin!

Step 1) Create a Yarn repository

Since Yarn is not yet available on Debian 10’s official repository, we are going to locally add the Yarn’s repo manually on our system. But first, let’s update and upgrade the system packages:

$ sudo apt update -y
$ sudo apt upgrade -y


Next, we are going to install the GPG signing key as shown:

$ curl -sS | sudo apt-key add -


To create the Yarn repository, run the command:

$ echo "deb stable main" | sudo tee /etc/apt/sources.list.d/yarn.list


Step 2) Install Yarn

With the repository created, re-synchronize the system packages by updating the system:

$ sudo apt update -y

Finally, to install Yarn run the command:

$ sudo apt install yarn


Once the installation is complete, you can check the version of Yarn installed by running the command:

linuxtechi@debian10:~$ yarn -v
linuxtechi@debian10:~$ yarn -v

Perfect ! We have successfully installed Yarn on Debian 10. Let’s now see a few use cases of how yarn can be used.

How to use Yarn

Yarn writes dependencies on the package.json file that is located on the root folder of your project and stores these dependencies in the node_modules directory.

To initialize a project simply run the command:

$ yarn init

A series of questions will be asked to which you will be required to answer accordingly. You can opt to leave some of them blank if you so wish.


The initialization of a new project creates a package.json file as mentioned earlier that contains the details you have just provided. To view the file, run

$ cat package.json


To install a package, us the syntax:

$ yarn add package

For example, to install express run the command:

$ yarn add express


To upgrade package, run

$ yarn upgrade package

If you wish to upgrade all your packages, run:

$ yarn upgrade


To remove a package, use the syntax

$ yarn remove package

For example:

$ yarn remove express


And that’s just about it as far as the installation of yarn is concerned. Yarn is a package Manager that is slowly but surely gaining traction and looking to replace Node’s NPM package manager. It’s fast and allows developers to share code in a seamless and secure way.

Share on:

James Kiarie, a certified Linux administrator and a passionate tech enthusiast who stays connected with the latest trends in the tech world. Beyond executing commands on the terminal, you'll find me enjoying some cool music, taking casual strolls, or indulging in a good movie.

1 thought on “How to Install Yarn on Debian 10”

Leave a Comment