How to Install Yarn on Debian 10

Install Yarn on Debian

Yarn is an advanced package management tool for Javascript applications mostly used for Node.js applications. Yarn is compatible with npm used for installing, configuring, updating and removing npm packages. It helps to solve problems with npm like network connectivity issues, speeding up the installation process, etc. In this tutorial, we are going to install Yarn on Debian 10.


Before you start to install Yarn on Debian 10. You must have the non-root user account on your system with sudo privileges.

Install Yarn on Debian

First, you will need to add the Yarn APT repository to your system. Then you will install Yarn on Debian.

Now import Yarn repositories GPG key using the following command to enable the Yarn repository using following curl command:

curl -sS | sudo apt-key add -

After importing key add Yarn APT repository using the following command:

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

Update the APT package manager index and install Yarn using the following commands. The following command will also install Node.js when installing Yarn.

sudo apt update
sudo apt install yarn

If you don’t want to install Node.js automatically with Yarn then use the following command:

sudo apt install --no-install-recommends yarn

Now confirm installation and check the version of Yarn using the following command:

yarn --version

The output should look like:


Examples of Using Yarn

Create a new Project

You can create a new project using Yarn running following command. This command will also ask you some questions please press ENTER to use default values or type answer.

sudo yarn init new_project

NOTE: Now it will create package.json file saving information provided by you. You can also edit the information inside the file anytime.

The above command output should look like:

yarn init v1.13.0
question name (vagrant): Linux4one
question version (1.0.0): 0.0.1
question description: Testing Yarn
question entry point (index.js): 
question repository url: 
question author: Linux4one
question license (MIT): 
question private: 
success Saved package.json
Done in 17.56s.

Install all dependencies

To install all the dependencies given inside package.json file use following command

yarn install

The above command will install all the dependencies given in package.json file.

Add dependency

Following is the basic syntax for adding the dependency:

yarn add [package_name]
yarn add [package_name]@[version_number_or_tag_name]

The above command will add the dependency to your project updating yarn.lock and package.json files.

Remove dependency

The basic syntax for removing dependency is given below:

yarn remove [package_name]

The above command removes specific dependency from your project updating yarn.lock and package.json files.

Update dependency

The basic syntax for upgrading dependency is given below:

yarn upgrade [package_name]
yarn upgrade [package_name]@[version_number_or_tag_name]

The above command will upgrade specific package to the latest version in your project then updates yarn.lock and package.json files.


You have successfully learned how to install Yarn on Debian 10. If you have any queries regarding this then please don’t forget to comment below.