How To Install Yarn on CentOS Stream 10 – Complete Guide

install Yarn CentOS Stream 10

Yarn is a fast, secure, and reliable JavaScript package manager widely used in modern web development. It is an alternative to NPM and is designed to improve dependency management, performance, and reproducibility.

With the release of CentOS Stream 10, many developers and system administrators are looking for updated and reliable ways to install development tools. In this guide, you will learn how to install Yarn on CentOS Stream 10 using multiple supported methods, including Corepack, NPM, and the official Yarn repository.

This tutorial is suitable for developers, DevOps engineers, and Linux system administrators.

What Is Yarn?

Yarn is a JavaScript package manager created by Facebook to address performance and consistency issues found in traditional package managers.

Key features of Yarn include:

  • Faster dependency installation
  • Deterministic builds using lock files
  • Improved security
  • Offline cache support
  • Better dependency resolution

Yarn is commonly used with frameworks such as React, Vue, Next.js, and Node.js-based applications.

Prerequisites

Before installing Yarn on CentOS Stream 10, make sure you have:

  • CentOS Stream 10 server or desktop
  • Root or sudo privileges
  • Internet connection
  • Node.js installed (required for most methods)

Check your OS version:

cat /etc/os-release

Step 1: Install Node.js on CentOS Stream 10

Yarn requires Node.js. The recommended way is using NodeSource.

Install Node.js LTS

sudo dnf install -y curl
curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo bash -
sudo dnf install -y nodejs

Verify installation:

node -v
npm -v

Method 1: Install Yarn Using Corepack (Recommended)

Corepack is an official Node.js tool that manages package managers like Yarn and PNPM.

Enable Corepack

sudo corepack enable

Install and Activate Yarn

corepack prepare yarn@stable --activate

Verify Yarn Installation

yarn --version

✅ This is the recommended and future-proof method for installing Yarn.

Method 2: Install Yarn Using NPM

If you prefer the traditional approach, you can install Yarn globally using NPM.

Install Yarn via NPM

sudo npm install -g yarn

Verify Installation

yarn --version

⚠️ Note: This method depends on NPM and may not always provide the latest stable Yarn version.

Method 3: Install Yarn from the Official Repository

This method installs Yarn directly from the official Yarn RPM repository.

Add Yarn Repository

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

Install Yarn

sudo dnf install -y yarn

Verify Installation

yarn --version

💡 This method installs Yarn system-wide and is useful for server environments.

Step 2: Verify Yarn Functionality

Create a test project:

mkdir yarn-test
cd yarn-test
yarn init -y

Install a sample package:

yarn add lodash

If no errors appear, Yarn is working correctly.

Managing Yarn Versions

Check Yarn version:

yarn --version

Update Yarn using Corepack:

corepack prepare yarn@latest --activate

This ensures consistent Yarn versions across development environments.

Common Issues and Troubleshooting

Yarn Command Not Found

Make sure Yarn is in your PATH:

which yarn

Restart your shell:

exec $SHELL

Permission Errors

Avoid using sudo with Yarn unless installing globally. For project dependencies, run Yarn as a normal user.

Yarn vs NPM: Which One Should You Use?

FeatureYarnNPM
SpeedFasterSlower
Lock fileyarn.lockpackage-lock.json
Offline cacheYesLimited
Deterministic buildsYesYes

Yarn is often preferred for large projects and monorepos.

Security Best Practices

  • Always use yarn.lock
  • Avoid running Yarn as root
  • Keep Node.js and Yarn updated
  • Audit dependencies regularly

Use Cases for Yarn on CentOS Stream 10

  • Web application development
  • CI/CD pipelines
  • Frontend build servers
  • Microservices environments
  • Node.js production builds

Conclusion

Installing Yarn on CentOS Stream 10 is straightforward and flexible, thanks to multiple supported installation methods. For most users, Corepack is the recommended and future-proof solution, while NPM and the official repository remain valid alternatives.

With Yarn properly installed, you can manage JavaScript dependencies efficiently and build modern applications with confidence.

(Visited 1 times, 1 visits today)

You may also like