FedoraRHEL Based

How To Install Yarn on Fedora 43

Install Yarn on Fedora 43

Yarn is one of the most trusted JavaScript package managers in the developer ecosystem. Whether you’re building a React app, a Node.js REST API, or managing a full-stack monorepo, Yarn keeps your dependencies fast, deterministic, and secure. But on Fedora 43 specifically, the variety of installation methods can feel overwhelming — especially when some behave differently depending on how your system is configured.

This guide clears the confusion entirely. You’ll learn exactly how to install Yarn on Fedora 43 using five battle-tested methods: DNF, NPM, Corepack, NVM, and the official Yarn RPM repository. Every method includes verified terminal commands, expected outputs, and honest advice on which approach fits your workflow. Whether you’re setting up a fresh Fedora 43 workstation or adding Yarn to an existing development environment, you’ll walk away with a fully functional installation.

What Is Yarn and Why Do Developers Love It?

Yarn — short for Yet Another Resource Negotiator — is an open-source JavaScript dependency manager originally created by Facebook in collaboration with Google, Exponent, and Tilde. It was built to solve npm’s early weaknesses: slow installs, inconsistent builds across machines, and limited offline support.

Today, Yarn ships in two distinct flavors. Yarn Classic (v1.x) is the original version — stable, widely documented, and still maintained in maintenance mode at version 1.22.22. Modern Yarn (v2/v3/v4, collectively called Yarn Berry) is the actively developed branch, featuring Plug’n’Play (PnP) installs, zero-install support, and first-class monorepo tooling.

The choice between them matters in practice. Joining an existing project? It almost certainly uses Yarn Classic. Starting fresh and want cutting-edge performance? Yarn Berry is the better option. This guide covers both paths.

Why choose Yarn over npm?

  • Deterministic installs — The yarn.lock file pins exact package versions, eliminating the classic “works on my machine” problem.
  • Parallel downloads — Yarn fetches multiple packages simultaneously, making installs noticeably faster than sequential npm installs.
  • Offline caching — Previously downloaded packages are cached locally so you can install dependencies without an internet connection.
  • Workspace support — Yarn handles monorepos natively with first-class workspace commands, a feature teams at Meta and Google rely on daily.

Prerequisites

Before running a single command, confirm your system is ready:

  • A working Fedora 43 installation — a fresh OS install is recommended to avoid pre-existing dependency conflicts.
  • Terminal access (GNOME Terminal, Konsole, or any terminal emulator).
  • A non-root sudo user — avoid running everything as root, as it creates unnecessary security risks.
  • A stable internet connection for downloading packages and GPG keys.
  • Basic familiarity with Linux terminal commands.

All commands below are verified specifically for Fedora 43. Let’s get started.

Method 1: Install Yarn on Fedora 43 via DNF (Recommended)

The simplest and most reliable way to install Yarn on Fedora 43 is through the built-in DNF package manager. Fedora’s official repositories ship the yarnpkg package natively — meaning no third-party sources, no manual GPG key imports, and automatic updates alongside your regular system upgrades.

Step 1: Refresh and Update System Packages

Start with a clean, up-to-date system to avoid dependency resolution issues:

sudo dnf upgrade --refresh

Step 2: Install Yarn and Node.js

Install Yarn using its correct Fedora package name. Pay attention here: the package is named yarnpkg — not yarn — to avoid a naming collision with an unrelated Apache Hadoop utility. DNF automatically resolves and installs Node.js as a dependency.

sudo dnf install yarnpkg nodejs -y

Step 3: Verify the Installation

yarn --version
node --version

Expected output:

1.22.22
v22.20.0

Done. Yarn Classic is installed globally and is immediately available in every project directory. This is the recommended starting point for most Fedora 43 users because it’s the lowest-friction method available.

Note: If you need Modern Yarn (v4.x) with Plug’n’Play support, jump ahead to Method 3 — Corepack.

Method 2: Install Yarn on Fedora 43 via NPM

Already using Node.js and npm? This method is fast, universal, and requires zero repository configuration. It installs Yarn Classic globally through npm’s package registry, making it available system-wide in seconds.

Step 1: Install Node.js

sudo dnf install nodejs -y

Confirm both tools are available:

node --version
npm --version

Step 2: Install Yarn Globally

sudo npm install yarn -g

The -g flag installs Yarn globally, making the yarn command accessible from any project directory. If you only need Yarn within a specific project — not system-wide — omit -g and run npm install yarn from inside your project folder instead.

Step 3: Confirm the Installation

yarn -v

Expected output: 1.22.21 or 1.22.22

Pro Tip: If you hit EACCES: permission denied errors during a global npm install, it means your npm prefix directory is owned by root. Rather than forcing it with sudo, reconfigure npm’s global directory to a user-owned path — or better yet, switch to the NVM method below which handles permissions cleanly by design.

Method 3: Install Modern Yarn on Fedora 43 via Corepack

Corepack is the official, Node.js-endorsed approach for managing Yarn Modern (v2/v3/v4). It ships bundled with Node.js upstream but is not included in Fedora’s Node.js package by default — you’ll need to enable it manually. This method is the right choice for new projects, monorepo setups, or any environment requiring strict per-project Yarn version control.

Step 1: Install Node.js and Git

Git is required by yarn init on Modern Yarn projects:

sudo dnf install nodejs git -y

Step 2: Install and Enable Corepack

Install Corepack globally via npm, then activate it so Yarn and pnpm shims become available in your shell:

sudo npm install -g corepack
sudo corepack enable

Step 3: Initialize a Project with Modern Yarn

Create a new directory and initialize it with the -2 flag:

mkdir ~/my-project && cd ~/my-project
yarn init -2

The -2 flag instructs Corepack to bootstrap this project using Modern Yarn. On the first run, Corepack automatically downloads and pins the correct Yarn version. Verify it:

yarn --version

Expected output: 4.x.x (for example, 4.12.0)

A critical distinction with Modern Yarn: it operates per-project, not globally. Each project stores its Yarn version inside package.json under the packageManager field and its configuration in .yarnrc.yml. Two separate projects on the same machine can run entirely different Yarn versions without any conflict — a powerful guarantee for team environments.

Method 4: Install Yarn on Fedora 43 via NVM

Node Version Manager (NVM) is a go-to tool for developers who work across multiple Node.js versions simultaneously. Running a legacy React 16 project alongside a modern Next.js 15 app? NVM keeps each environment isolated and reproducible. Installing Yarn via NVM follows the same npm global approach as Method 2 — but scoped to whichever Node.js version is currently active.

Step 1: Install NVM

Run the official installation script:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash

Activate NVM in your current session without opening a new terminal:

source ~/.bashrc

Step 2: Install Node.js via NVM

Install the latest Long-Term Support (LTS) release:

nvm install --lts
nvm use --lts

Verify:

node --version

Step 3: Install Yarn

npm install -g yarn

Verify:

yarn --version

Important: With NVM, Yarn is installed per Node.js version. If you switch versions later with nvm use <version>, you may need to reinstall Yarn for that version. This is expected behavior — not a bug. Understanding this saves you from confusing “command not found” errors when jumping between projects.

Method 5: Install Yarn via the Official RPM Repository

For production server deployments or hardened environments where GPG-signed, repository-managed packages are a requirement, the official Yarn RPM repository is the most trustworthy source available.

Step 1: Ensure Node.js Is Installed

sudo dnf install nodejs -y

Step 2: Add the Official Yarn Repository

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

This command fetches Yarn’s repository configuration from its official servers and saves it to /etc/yum.repos.d/yarn.repo — the standard location DNF watches for repository definitions. GPG signature verification is included automatically.

Step 3: Install Yarn

sudo dnf install yarn -y

During the first installation, DNF imports the Yarn GPG key automatically. Confirm the import when prompted:

Importing OpenPGP key 0x6963F07F:
 Fingerprint: 9A6F73F34BEB74734D8C69149CBBB5586963F07F
 From: https://dl.yarnpkg.com/rpm/pubkey.gpg
Is this ok? [y/N]: y

Verify:

yarn --version

Expected: 1.22.22

Configure Yarn’s Global Binary PATH

This is a step most guides skip — and it causes the most post-installation frustration. When you install packages globally with yarn global add <package>, Yarn places executables in its global bin directory. But unless that directory is registered in your system’s $PATH, those executables won’t run from the terminal.

Add Yarn’s global bin to your PATH permanently:

echo 'export PATH="$PATH:$(yarn global bin)"' >> ~/.bashrc
source ~/.bashrc

Confirm the update worked:

echo $PATH

You should see Yarn’s global bin directory in the output. Without this step, commands like create-react-app or gatsby — installed via yarn global add — will appear to install successfully but throw “command not found” errors on use. It’s a tiny step that prevents a big headache.

Essential Yarn Commands for Daily Development

With Yarn installed and configured, here are the commands you’ll reach for most often:

Command What It Does
yarn init Initialize a new project and create package.json
yarn init -y Initialize with all defaults, no prompts
yarn add <package> Install a dependency and update package.json
yarn add <package> --dev Install a development-only dependency
yarn add <package>@<version> Install a specific package version
yarn install Install all deps defined in yarn.lock
yarn remove <package> Uninstall a package and update package.json
yarn upgrade Upgrade all packages within declared version ranges
yarn upgrade-interactive Interactively choose which packages to upgrade
yarn global add <package> Install a package globally
yarn run <script> Run a script defined in package.json
yarn cache clean Clear Yarn’s local package cache

Never delete yarn.lock and always commit it to version control. This file is the backbone of reproducible builds — it guarantees every developer on your team and every CI/CD pipeline installs exactly the same package versions, byte for byte.

Troubleshooting Common Yarn Issues on Fedora 43

Clean installs occasionally hit snags. These are the most frequent issues Fedora users encounter, along with their solutions.

yarn: command not found After Installation

Almost always a PATH issue. Run source ~/.bashrc to reload your shell configuration. If you used the DNF method, your binary might be named yarnpkg instead of yarn. Create a permanent alias:

echo "alias yarn=yarnpkg" >> ~/.bashrc
source ~/.bashrc

Permission Denied During Global Package Installs

Avoid adding sudo before npm or Yarn commands as a “fix” — it worsens permissions over time. Instead, redirect Yarn’s global directory to a user-owned path:

yarn config set prefix ~/.yarn-global
echo 'export PATH="$PATH:$HOME/.yarn-global/bin"' >> ~/.bashrc
source ~/.bashrc

GPG Key Import Failure (RPM Repository Method)

If the GPG key import fails, verify that curl is installed and your system can reach Yarn’s servers:

curl -I https://dl.yarnpkg.com

A failed connection usually means a firewall rule is blocking outbound traffic to that domain. In that case, switch to the DNF or NPM method as a workaround.

Conflicting Versions from Multiple Install Methods

If you’ve accidentally installed Yarn through more than one method, path conflicts cause unpredictable behavior. Clean up first, then reinstall cleanly:

sudo dnf remove yarnpkg -y
sudo npm uninstall yarn -g

Reinstall using your one preferred method.

Network Timeouts During Package Installation

For slow or unstable connections producing ETIMEDOUT errors, increase Yarn’s default network timeout:

yarn config set network-timeout 300000
yarn install

The value is in milliseconds — 300000 equals five full minutes. For proxy environments, configure Yarn accordingly:

yarn config set proxy http://your.proxy:port
yarn config set https-proxy http://your.proxy:port

Clearing a Corrupted Cache

Corrupted cache entries cause mysterious, hard-to-diagnose installation failures. Clearing the cache usually fixes them instantly:

yarn cache clean
yarn install

How to Uninstall Yarn from Fedora 43

Removing Yarn cleanly depends on how it was originally installed. Match the removal command to your method:

DNF (Fedora repo):

sudo dnf remove yarnpkg -y && sudo dnf autoremove -y

NPM global install:

npm uninstall -g yarn

Corepack / Modern Yarn:

corepack disable

Then delete the .yarn folder from any project that used it.

Official RPM repository:

sudo dnf remove yarn -y
sudo rm /etc/yum.repos.d/yarn.repo

After any removal, clean up leftover configuration and cache files:

rm -rf ~/.yarn ~/.yarnrc ~/.cache/yarn ~/.yarn-global

Verify Yarn is fully removed:

yarn --version
# Expected: bash: yarn: command not found

Congratulations! You have successfully installed Yarn. Thanks for using this tutorial for installing Yarn package manager on Fedora 43 Linux system. For additional help or useful information, we recommend you check the official Yarn website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button