Skip to content

How to Install Yarn on CentOS/RHEL & Fedora

3 Ways to Install Yarn on CentOS & Fedora. The yarn is an advanced package management software for Node.js applications. This tutorial contains three ways to install Yarn on CentOS, Redhat, & Fedora system. Use one of the following ways:

Covers
CentOS, Fedora, Node.js
On this page

In this comprehensive guide, we’ll explore the methods of installing Yarn on CentOS, Redhat, and Fedora systems. Yarn is a highly sophisticated package management tool specifically designed for Node.js applications, offering a fast, secure, and reliable alternative to other Node.js package managers. Whether you’re a seasoned developer or new to Node.js, understanding how to install Yarn can enhance your development workflow.

Here, we’ll delve into three distinct methods to install Yarn, each suited for different requirements and system setups.

Method 1: Install Yarn Using NPM

One straightforward approach to install Yarn is through NPM, a widely-used package manager for JavaScript. By employing NPM, you can effortlessly install Yarn globally across your system. This global installation allows you to use Yarn in any Node.js project on your machine. To install Yarn globally, execute the following command:

sudo npm install yarn -g 

Alternatively, if you prefer to install Yarn specifically for a single project rather than globally, simply omit the -g option from the command. This localized installation is particularly useful for managing dependencies on a project-by-project basis.

Once the installation is complete, you can verify the installed version of Yarn by running:

yarn -v 

You should see the version number, such as 1.22.21, confirming that Yarn is successfully installed.

Method 2: Install Yarn Using a Bash Script

For a more tailored installation, using a script to install Yarn is highly recommended. This method involves downloading a Yarn archive and extracting it into the .yarn directory in your home folder. The beauty of this approach is that it automatically sets the PATH environment variable, ensuring that Yarn is easily executable from the command line. To install Yarn using this method, use the following command:

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

This script-based installation is particularly advantageous as it makes Yarn available only to the current user, providing a more secure and user-specific setup.

Method 3: Install Yarn Using Yum Package Manager

For those preferring to work with Yum, a popular package manager for Linux distributions, Yarn can be installed using Yum as well. This method is quite straightforward and involves configuring the official Yarn repository on your system. Start by adding the Yarn repository using the following command:

curl -sL https://dl.yarnpkg.com/rpm/yarn.repo -o /etc/yum.repos.d/yarn.repo 

Once the repository is configured, you can proceed to install Yarn. The command differs slightly based on your operating system.

sudo yum install yarn 

Use ‘yum’ for older versions of operating systems:

Each of these methods offers a reliable way to install Yarn on your CentOS, Redhat, or Fedora system. Choose the one that best suits your setup and preferences. With Yarn installed, you’re now ready to manage your Node.js application packages more efficiently and securely.

Rahul

Rahul Kumar is the founder and chief editor of TecAdmin.net. A Red Hat Certified Engineer (RHCE), he has worked in IT since 2009, with hands-on experience in Linux system administration, DevOps, web hosting, cloud platforms and automation. He started TecAdmin in 2013 to share practical, step-by-step guides, and leads its editorial work with one aim: making technical learning clear and useful for sysadmins, developers and beginners alike.

4 Comments

  1. YARN is nothing but a package manager for the code that we want to run on our system and it allows us to use and share the code with the other. To use it on your system, first, you need to install it. The installation process is quite simple for you, You just follow the steps given here.

Leave a Reply

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


Back to top