If you're learning React on Linux Mint, one of the first things you'll need is a JavaScript package manager. While npm comes bundled with Node.js, many React projects also use Yarn.
In this guide, I'll show you how I installed Yarn on Linux Mint after installing Node.js using NVM (Node Version Manager). This is the recommended approach because it keeps your Node.js and package manager versions organized and easy to update.
Prerequisites
Before installing Yarn, make sure you already have:
- Node.js installed using NVM
- npm (installed automatically with Node.js)
You can verify your installation by running:
node -v
npm -v
which node
which npm
My output looked like this:
If your node and npm paths point to your .nvm directory, then you're ready to install Yarn.
Why I Didn't Install Yarn with npm
Earlier, it was common to install Yarn globally using:
npm install -g yarn
However, if you're using a modern version of Node.js (like Node.js 18, 20, 22, or newer), there's a better way.
Node.js now includes Corepack, a tool that manages package managers like Yarn and pnpm. This means you don't need to install Yarn globally with npm.
Step 1: Check if Corepack is Available
Run:
corepack --version
If you see a version number, Corepack is already installed.
Step 2: Enable Corepack
Enable it by running:
corepack enable
You only need to do this once.
Step 3: Install the Latest Stable Version of Yarn
Run:
corepack prepare yarn@stable --activate
Depending on your Corepack version, you can also use:
corepack use yarn@stable
Both commands activate the latest stable version of Yarn.
Step 4: Verify the Installation
Finally, check the installed version:
yarn --version
If a version number is displayed, Yarn has been installed successfully.
Verify Everything
You can also confirm your complete setup with:
node -v
npm -v
corepack --version
yarn --version
Everything should return version numbers without any errors.
Creating Your First React Project
Once Yarn is installed, creating a new React project with Vite is simple:
yarn create vite my-app
Move into the project folder:
cd my-app
Install the project dependencies:
yarn
Start the development server:
yarn dev
Open the URL shown in the terminal (usually http://localhost:5173) to see your React application running.
Why This Method Is Better
Using NVM together with Corepack offers several benefits:
- Keeps Node.js versions easy to manage.
- Uses the officially recommended way to install Yarn.
- Avoids installing Yarn globally with npm.
- Makes switching between different JavaScript projects much easier.
- Works well with modern React and Vite applications.
Final Thoughts
If you're using Linux Mint and have installed Node.js through NVM, installing Yarn with Corepack is the cleanest and most future-proof approach.
The setup only takes a few minutes, and once it's done, you're ready to build modern React applications with Vite.
In my next post, I'll show you how to create your first React project using Vite and explain the folder structure so you can understand what each file does.



Top comments (0)