Install Yarn on Debian 11

0
26

Follow through this guide to learn how to install Yarn on Debian 11. Yarn is an acronym for Yet Another Resource Navigator. Yarn is a fast, secure and reliable JavaScript package manager that is compatible with npm registry and can be used with npm.

Install Yarn on Debian 11

There are multiple ways in which you can install:

Install Yarn on Debian 11 via npm

In order to install Yarn via NPM, you need to have NPM installed.

You can install latest Nodejs Package Manager on Debian 11. Nodejs 16.x is the current stable release based on the releases page.

apt install curl sudo -y
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -

Next, run the command below to install Node.js 16.x and npm

apt install nodejs

Check Nodejs package manager version

npm -v
7.20.3

Now that NPM is already installed, you can then install Yarn on Debian 11 via npm using the command below;

npm install --global yarn 

Checking the version of installed Yarn on Debian 11;

yarn -v
1.22.11

Uninstall Yarn

If for some reasons you want to uninstall Yarn, you can use the command below;

npm uninstall -g yarn

Install Yarn on Debian 11 via APT

To install Yarn via APT, you need to ass the Yarn APT repo as shown in the commands below;

curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
apt update
apt install yarn

Please note this method may not get you the latest version of yarn though.

The command above installs both Yarn and NPM;

yarn -v
1.22.5
npm -v
7.20.3

Install Yarn on Debian 11 via install Script

The easiest way to install Yarn on Debian 11 is via install script. However, note that also, the script installation may not install the latest version of Yarn.

To install Yarn via the install script, you need to have Nodejs installed.

curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
apt install nodejs

You can simply run the command below to download and run the Yarn installation script.

apt install curl tar
curl -o- -L https://yarnpkg.com/install.sh | bash

Sample command output;

...
> GPG signature looks good
> Extracting to ~/.yarn...
> Adding to $PATH...
> Successfully installed Yarn 1.22.5! Please open another terminal where the `yarn` command will now be available.

The script don’t install yarn globally and hence, it can only be used under your profile.

less ~/.bashrc
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"

Source your bashrc and verify the Yarn version:

source ~/.bashrc
yarn -v

That marks the end of our tutorial on how to install Yarn on Debian 11.

Read more on Yarn Documentation page.

Other Tutorials

Install PHP 7.1/7.2/7.3/7.4 on Debian 11

Install PHP 8 on Debian 11

Install Latest Nodejs on Rocky Linux 8

LEAVE A REPLY

Please enter your comment!
Please enter your name here