search
node

Fix: yarn: command not found error

Quick fix for 'yarn: command not found' error. Learn how to install and configure Yarn package manager on different operating systems.

person By Gautam Sharma
calendar_today January 8, 2026
schedule 2 min read
Node.js Package Manager Yarn Error Fix Installation

The ‘yarn: command not found’ error occurs when the Yarn package manager is not installed or not properly added to the system’s PATH, preventing command-line access to Yarn commands.


How the Error Happens

❌ Error Scenario:

# ❌ This causes the error
yarn install
# Error: yarn: command not found

✅ Quick Fix - Install and Configure Yarn

Solution 1: Install Yarn via npm

# ✅ Install Yarn globally using npm
npm install -g yarn

# ✅ Verify installation
yarn --version

Solution 2: Install via Package Manager

# ✅ On macOS with Homebrew
brew install yarn

# ✅ On Windows with Chocolatey
choco install yarn

# ✅ On Windows with Scoop
scoop install yarn

# ✅ On Ubuntu/Debian
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn

# ✅ On CentOS/RHEL/Fedora
sudo curl -sL https://dl.yarnpkg.com/rpm/yarn.repo -o /etc/yum.repos.d/yarn.repo
sudo yum install yarn
# ✅ Enable Corepack (Node.js 14.19+ or 16.9+)
corepack enable

# ✅ Install Yarn
corepack prepare yarn@stable --activate

Solution 4: Install via Standalone Script

# ✅ Download and install Yarn
curl -o- -L https://yarnpkg.com/install.sh | bash

# ✅ Or using npm with npx
npx yarn install
Gautam Sharma

About Gautam Sharma

Full-stack developer and tech blogger sharing coding tutorials and best practices

Related Articles

node

Fix: pnpm: command not found error

Quick fix for 'pnpm: command not found' error. Learn how to install and configure pnpm package manager on different operating systems.

January 8, 2026
node

Fix: Error: spawn ENOENT error

Quick fix for 'Error: spawn ENOENT' error in Node.js. Learn how to resolve child process spawn issues and command execution problems.

January 8, 2026
node

Fix: ExperimentalWarning: Importing JSON modules error

Quick fix for 'ExperimentalWarning: Importing JSON modules' error in Node.js. Learn how to properly import JSON files in modern Node.js applications.

January 8, 2026