How To Install Yarn On CentOS 7

How to Install Yarn on CentOS 7

Yarn is a JavaScript package manager compatible with npm that helps you automate the process of installing, updating, configuring, and removing npm packages. It was created to solve a set of problems with the npm such as speeding up the packages installation process by parallelizing operations and reducing errors related to network connectivity. Before all, find a good provider to set up your own VPS.



To let this tutorial work better, please consider the below Prerequisites:

A non-root user with sudo privileges.



Recommended Article: How To Secure MongoDB On Ubuntu 20.04 Server

How To Install Yarn On CentOS 7

Yarn is an ultra-fast dependency management application designed to cache the packages it downloads so they never need not be downloaded again. It is a secure and reliable program that parallelizes all operations to boost resource utilization and expedite install times.

Join us with this guide to verify How to Install Yarn on CentOS 7 system from the Yarn RPM package repository. In case you are using the new version, find your guide on How to install Yarn on CentOS 8.


Step 1: Installing Yarn on CentOS

If you already don’t have Node.js installed on your system, enable the Nodesource repository.

curl --silent --location | sudo bash -

Install the Node.js package by typing:

sudo yum install nodejs

The official Yarn repository is consistently maintained and provides the most up-to-date version. To enable the Yarn repository and import the repository’s GPG key issue the following commands:

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

Once the repository is added, you can install Yarn, by running:

sudo yum install yarn

Then, verify the installation by printing the Yarn version number:

yarn --version

At the time of writing this article, the latest version of Yarn is version 1.17.3.





Step 2: Using Yarn

Now that you have Yarn installed on your CentOS system, we’ll explore some of the most common Yarn commands.



Creating a new project

To create a new Yarn project use the yarn init command followed by the project name. For example, to create a project named my_project you would type:

yarn init my_project

The script will ask you several questions. You can either answer or press enter to use the default values:


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

Once completed, the script will create a basic package.json file that contains the information you provided. You can open and edit this file at any time.



Adding Dependency

To upgrade the packages, use one of the following commands:

yarn upgrade
yarn upgrade [package_name]
yarn upgrade [package_name]@[version_or_tag]

If no package name is given, the command will update the project dependencies to their latest version according to the version range specified in the package.json file. Otherwise, only the specified packages are updated.



Upgrading Dependency

To upgrade a dependency use one of the following:

yarn upgrade [package_name]
yarn upgrade [package_name]@[version_or_tag]

The command above will update the project dependencies to their latest version according to the version range specified in the package.json file.



Removing Dependency

To remove a dependency simply type:

yarn remove [package_name]    

This command will also update the project’s package.json and yarn.lock files.

Step 3: Installing All Project Dependencies

Therefore, in this step to install all the dependencies of an existing project that are specified in the package.json file run:



yarn install





In this article, you have successfully installed Yarn on CentOS 7. Also, you understand the basic Yarn usage commands and it should not be difficult to get started. If you want in-depth details on how to use Yarn, go to the official Yarn documentation web page. Find more related articles if you use another OS or windows.

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 7

    1. Sine Yarn package is available to install with NPM, you can run the command below to install Yarn globally.
      sudo npm install yarn –g
      Note: If you remove –g option, you can install the current project only.

    1. Yarn and NPM are so close in competition but Yarn considerably faster, opposite of that, NPM 5 introduced a package-lock, which allows for deterministic dependency installation.

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