AMP AMP

How to Install Yarn On Debian 11.4

To Install Yarn On Linux Debian 11.4

Introduction:

The yarn is a fast, secure, and reliable advanced package management software for Node.js applications that is an alternative to Node.js package managers.

Installation Procedure:

Step 1: Check the version of the OS by using the below command

root@debian:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye

Step 2: Check the IP address by using the below command

root@debian:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:ea:5e:31 brd ff:ff:ff:ff:ff:ff
    altname enp2s1
    inet 192.168.6.131/23 brd 192.168.7.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:feea:5e31/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

Step 3: Install the Yarn, then enable the Yarn repository by using the below command

root@debian:~# curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
OK
Step 4: Once the repository is enabled. Add the yarn repository to the system repository by using the below command
root@debian:~# echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
deb https://dl.yarnpkg.com/debian/ stable main

Step 5: The repository is added now update and install the yarn by using the below command

root@debian:~# sudo apt-get update && sudo apt-get install yarn
Get:1 http://security.debian.org/debian-security bullseye-security InRelease [48.4 kB]
Get:2 http://deb.debian.org/debian bullseye-updates InRelease [44.1 kB]
Hit:3 http://deb.debian.org/debian bullseye InRelease
Hit:4 http://dl.google.com/linux/chrome/deb stable InRelease
Get:5 https://dl.yarnpkg.com/debian stable InRelease [17.1 kB]
Get:6 https://dl.yarnpkg.com/debian stable/main amd64 Packages [10.9 kB]
Get:7 https://dl.yarnpkg.com/debian stable/main all Packages [10.9 kB]
Fetched 131 kB in 1s (93.1 kB/s)
Reading package lists... Done
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:21 and /etc/apt/sources.list.d/google-chrome.list:3
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:21 and /etc/apt/sources.list.d/google-chrome.list:3
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  dbconfig-common dbconfig-mysql default-mysql-client galera-4 icc-profiles-free
The following NEW packages will be installed:
  libc-ares2 libjs-highlight.js libnode72 nodejs nodejs-doc yarn
0 upgraded, 6 newly installed, 0 to remove and 28 not upgraded.
Need to get 12.4 MB of archives.
After this operation, 56.0 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://security.debian.org/debian-security bullseye-security/main amd64 libc-ares2 amd64 1.17.1-1+deb11u3 [102 kB]
Get:2 http://deb.debian.org/debian bullseye/main amd64 libjs-highlight.js all 9.18.5+dfsg1-1 [397 kB]
Get:3 http://security.debian.org/debian-security bullseye-security/main amd64 libnode72 amd64 12.22.12~dfsg-1~deb11u4 [8,332 kB]
Unpacking yarn (1.22.19-1) ...
Setting up libc-ares2:amd64 (1.17.1-1+deb11u3) ...
Setting up nodejs-doc (12.22.12~dfsg-1~deb11u4) ...
Processing triggers for man-db (2.9.4-2) ...
Processing triggers for libc-bin (2.31-13+deb11u6) ...

Step 6: The yarn is installed then install the packages of the yarn by using the below command

root@debian:~# curl -o- -L https://yarnpkg.com/install.sh | bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    54    0    54    0     0    339      0 --:--:-- --:--:-- --:--:--   339
100  7152  100  7152    0     0  11801      0 --:--:-- --:--:-- --:--:-- 11801
Installing Yarn!
> Downloading tarball...
[2/2]: https://yarnpkg.com/latest.tar.gz.asc --> /tmp/yarn.tar.gz.p2up2WQ1fZ.asc
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    61    0    61    0     0   1129      0 --:--:-- --:--:-- --:--:--  1129
100    98  100    98    0     0   1065      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   833  100   833    0     0    952      0 --:--:-- --:--:-- --:--:--   952
> Verifying integrity...
gpg: key 1646B01B86E50310: public key "Yarn Packaging <yarn@dan.cx>" imported
gpg: Total number processed: 1
Primary key fingerprint: 72EC F46A 56B4 AD39 C907  BBB7 1646 B01B 86E5 0310
     Subkey fingerprint: 6D98 490C 6F1A CDDD 448E  4595 4F77 6793 6947 5BAA
> GPG signature looks good
> Extracting to ~/.yarn...
> Adding to $PATH...
> We've added the following to your /root/.bashrc
> If this isn't the profile of your current shell then please add the following to your correct profile:

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

> Successfully installed Yarn 1.22.19! Please open another terminal where the `yarn` command will now be available.

Step 7: Once the package is installed. Now check the version of yarn by using the below command

root@debian:~# yarn -v
1.22.19

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to install Yarn on Linux Debian 11.4. Your feedback is much welcome.

FAQ
Q
What is the command to check the version of Yarn?
A
The command is # yarn -v
Q
How do you install Yarn packages on Linux Mint?
A
The command is # curl -o- -L https://yarnpkg.com/install.sh | bash
Q
How do you add the yarn repository to the system repository?
A
The command is # echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
Q
How do you enable the Yarn Repository?
A
To enable the Yarn Repositor command use # curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
Q
What is Yarn software?
A
The yarn is an advanced package management software for Node.js applications. It is a fast, secure, and reliable alternative that any other Nodejs package manager.