Install Yarn on Rocky Linux 8

|
Last Updated:
|
|

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

Installing Yarn on Rocky Linux 8

Prerequisites

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

Install latest Nodejs Package Manager on Rocky Linux. Nodejs 16.x is the current stable release based on the releases page.

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

Nodejs installs NPM.

npm -v
7.18.1

Installing Yarn on Rocky Linux 8

There are multiple ways in which you can install:

Install Yarn via npm

Assuming that NPM is already installed, you can then install Yarn via npm using the command below;

npm install --global yarn 

Checking the version of installed Yarn on Rocky Linux 8;

yarn -v
1.22.10

Uninstall Yarn

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

npm uninstall -g yarn

Install Yarn via DNF/YUM

Once you have NPM installed via the Nodejs, you can install Yarn via the YUM repository by running the commands below;

curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
dnf install yarn

Install Yarn via install Script

The easiest way to install Yarn is via install script. You can simply run the command below to download and run the Yarn installation script.

dnf 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...
> 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.5! Please open another terminal where the `yarn` command will now be available.

The script dont install yarn globally and so if you can update your PATH environment variable as shown from the command output.

Source your bashrc and verify the Yarn version:

source ~/.bashrc
yarn -v

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

Read more on Yarn Documentation page.

Other Tutorials

Install Latest Nodejs on Rocky Linux 8

Install PHP Composer on Rocky Linux 8

Install PHP 8.0 on Rocky Linux 8

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
koromicha
I am the Co-founder of Kifarunix.com, Linux and the whole FOSS enthusiast, Linux System Admin and a Blue Teamer who loves to share technological tips and hacks with others as a way of sharing knowledge as: "In vain have you acquired knowledge if you have not imparted it to others".

Leave a Comment