How To Install Yarn On CentOS 8

How to install Yarn on CentOS 8

Tutorial How To Install Yarn On CentOS 8 Linux. Created by Facebook, join us to learn install Yarn on CentOS 8 server. In this article, you will learn about the coolest and latest package manager for NodeJS which has come to replace npm. While npm works just okay, Yarn ships with some improvements that give it a competitive edge over npm. In fact, developers are now migrating their Node.JS projects over to Yarn.

Firstly, Yarn dwarfs npm in terms of speed of package installation. Yarn is much faster than npm and installs packages simultaneously making it a better choice than npm.

And also, when a package is installed, a global cache is installed containing all the dependencies. This does away with the need to going back online to download them again and makes subsequent installation much faster.

Secondly, Yarn is considered more secure than npm. This is because it installs packages from the package.json or yarn.lock files.

Additionally, Yarn.lock guarantees that the same package is installed across all the devices thereby keeping away bugs arising from the installation of different versions. In contrast, npm installs packages from dependencies that raise security concerns due to inconsistencies in the package versions installed.

Recommended Article: 5 Awesome Tips About Partition Ubuntu 20.04 with NVME Storage

How To install Yarn On CentOS 8

Let’s start with this guide to be an expert at How to install Yarn on CentOS 8. To make your study more useful, contact the Eldernode team as a VPS provider to have your own Linux Virtual Server. In case you need the guidance of the previous version, find our article on How To Install Yarn On CentOS 7.

1- How To Install NodeJS In CentOS 8

Log in to your CentOS 8 system as a root user and install the EPEL repository.

yum install epel-release

Use the following command to install NodeJS on CentOS 8.

yum module install nodejs

Run the command below to confirm the installation of Node.JS.

node -v  node --version


2- How To Enable Yarn Repository

Once the Node.js is installed, you need to enable the Yarn repository.

curl --silent --location | tee /etc/yum.repos.d/yarn.repo  

Then, to add the GPG key:

rpm --import  


3- How To Install Yarn in CentOS 8

Use the command below to install Yarn.

yum install yarn

To check the version of Yarn that you have installed:

yarn --version    1.21.1


4- How To Create A New Project In Yarn

In this step, create a new project using the yarn init command and later followed by the project’s name. For example:

yarn init my_first_project

After that, you will be prompted to answer a couple of questions. You can decide to answer Yes or No or simply hit ENTER to proceed to the next question.

package.json file is created at the end and you can confirm it.

ls -l package.json

This file contains all the info you have just provided.

To view the contents of it:

cat package.json


5- How To Install Packages Using Yarn

Install the package by typing:

yarn add [package_name]

For example,

yarn add express

Also, you can remove the package, simply by running:

yarn remove express




In this article, you learned How to install Yarn on CentOS 8. Please be aware that, Yarn comes with useful benefits that seek to compensate for npm’s shortcomings. It’s much faster, secure and is gradually overtaking npm as Node’s favorite package manager. With Yarn, you can deploy your projects with ease and comfort while avoiding the inconveniencies that are occasioned with npm. In a nutshell, Yarn is the better of the two. If you need to see the same guide for windows OR Ubuntu, check them on our website.

How useful was this post?

Click on a star to rate it!

Average rating 1 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

View More Posts
Marilyn Bisson
Content Writer
Eldernode Writer
We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

10 thoughts on “How To Install Yarn On CentOS 8

    1. While the npm install command installs dependencies from the package. json file and allows you to add new packages, The yarn install only installs the dependencies listed in yarn.

    1. If you need to add a package as dependency to your project, run (yarn add) followed by the package name:
      yarn add [package_name]

    1. You can use any of the following commands to upgrade the packages.
      • yarn upgrade
      • yarn upgrade [package_name]
      • yarn upgrade [package_name]@[version_or_tag]

    1. Yes sure. The simplest and easiest way to install Yarn from the script available at the Yarn official website with the following command:
      curl -o- -L | bash

Leave a Reply

Your email address will not be published. Required fields are marked *

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way


7 days a week, 24 hours a day