Atlantic.Net Blog

How to Install Yarn on CentOS 8

Hitesh Jethva
by Atlantic.Net (64posts) under VPS Hosting
0 Comments

Yarn is an advanced package management tool released by Facebook for JavaScript applications. Yarn is mostly used for Node.js applications and is compatible with npm, meaning it can install, remove, configure and update npm packages. It was specially designed to speed up package installation process.

In this guide, we will explain different ways to install Yarn on CentOS 8.

Prerequisites

  • A fresh CentOS 8 VPS on the Atlantic.Net Cloud Platform.
  • A root password configured on your server.

Step 1 – Create Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server.  Create a new server, choosing CentOS 8 as the operating system with at least 1GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Once you are logged into your CentOS 8 server, run the following command to update your base system with the latest available packages.

dnf update -y

Step 2 – Install Yarn

Install Yarn with NPM

You can install Yarn with NPM “Node Package Manager.” First, install Node.js with the following command:

dnf install @nodejs -y

Once installed, you can install the Yarn package globally using the following command:

npm install yarn -g

Once installed, you should see the following output:

You can now verify the version of Yarn with the following command:

yarn -v

You should see the following output:

1.22.4

Install Yarn with Script

The simplest and easiest way to install Yarn is to install it from the script available at the Yarn official website.

You can install download and run the Yarn installation script with the following command:

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

Once the installation has been finished, you should see the following output:

Note: This script will install Yarn only for the current user.

Next, activate the PATH environment variable for Yarn with the following command:

source ~/.bashrc

Next, verify the Yarn version with the following command:

yarn -v

You should see the following output:

1.22.4

Install Yarn from Repository

You can also install Yarn from the official repository.

First, add the Yarn repository with the following command:

curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo

You should see the following output:

Next, import the Yarn GPG key with the following command:

rpm --import https://dl.yarnpkg.com/rpm/pubkey.gpg

Finally, install Yarn by running the following command:

dnf install yarn -y

Next, verify the Yarn version with the following command:

yarn -v

You should see the following output:

1.22.4

Step 3 – Yarn Basic Command-line Usage

In this section, we will show some basic commands to create and manage the Yarn project.

To create a new Yarn project, run the following command:

yarn init projectname

This will create a package.json for your project.

You can now initiate a Yarn project in your current working directory with the following command:

yarn init

To install all the dependencies for your project specified in the package.json, run the following command:

yarn install

To add any package as a dependency in your project, run the following command:

yarn add packagename

To update any package dependencies, run the following command:

yarn upgrade packagename

To remove any package from the dependencies, run the following command:

yarn remove packagename

Conclusion

Congratulations! You have successfully installed Yarn on CentOS 8. You can now use your desired method to install Yarn in your system – try it today using your Atlantic.Net VPS Hosting. For more information, visit the Yarn official documentation page.

Get A Free To Use Cloud VPS

Free Tier Includes:
G2.1GB Cloud VPS Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


Looking for a Hosting Solution?

We Provide Cloud, Dedicated, & Colocation.

  • Seven Global Data Center Locations.
  • Flexible Private, Public, & Hybrid Hosting.
  • 24x7x365 Security, Support, & Monitoring.
Contact Us Now! Med Tech Award FTC
SOC Audit HIPAA Audit HITECH Audit

Recent Posts

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G2.1GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2323 Bryan Street,

Dallas, Texas 75201

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4

Canada

London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom

Resources