Install Yarn the modern way, powered by Corepack.
Install Yarn easily on Windows, macOS, or Linux. Use Corepack to manage Yarn versions and keep your JavaScript projects running smoothly.
Follow these simple steps to set up Yarn and start managing project dependencies.
Run these commands to install Yarn using Corepack:
$ npm install -g corepack $ corepack enable $ corepack install -g yarn@stable $ yarn --version
Already have Corepack? Skip the first command. Corepack helps your projects use the right Yarn version.
This guide covers installation, version checks, and common setup fixes.
Before You Install Yarn: What You Need
Before installing Yarn, check that Node.js, npm, and Corepack are available. These tools help ensure a smooth setup.
Check Node.js
Make sure Node.js is installed on your computer before setting up Yarn.
$ node --version
If Node.js is missing, download it from nodejs.org.
Check npm
npm normally comes with Node.js. Verify that it works correctly.
$ npm --version
A version number means npm is ready to use.
Check Corepack
Corepack manages Yarn versions for your projects. Check whether it is installed.
$ corepack --version
If Corepack is not found, you can install a compatible version in the next section.
Important Node.js and Corepack Compatibility
Corepack was bundled with some earlier Node.js releases but is no longer included starting with Node.js 25. If Corepack is unavailable, install a version compatible with your Node.js environment before proceeding.
How to Install Yarn Using Corepack
Corepack is the preferred method for modern Yarn because it can manage different Yarn versions for different projects. Follow these steps to configure Yarn.
Install Corepack if Needed
First check:
corepack --version
If Corepack is missing and your Node.js runtime supports the selected release, install it using:
npm install -g corepack
If npm reports an unsupported engine error, do not force the installation. Check your Node.js version and choose a compatible Corepack release.
Enable Corepack
Run:
corepack enable
This command sets up the shims that let Corepack handle supported package manager commands, including Yarn and pnpm. It may finish successfully without showing a detailed confirmation message, which is not necessarily an error.
Configure a Default Yarn Version
To prepare a default stable Yarn release, run:
corepack install -g yarn@stable
This provides a default Yarn version for
projects that do not specify another release.
When working with an existing repository,
inspect its packageManager field
before making changes to the Yarn configuration.
Related reading
To understand Corepack command shims and troubleshoot permission-related problems, see the Corepack Enable Guide .
Verify Yarn
Run:
yarn --version
You should see a Yarn version number.
You can also check the available Yarn commands:
yarn --help
If both commands run successfully, Yarn is available through your terminal. You can proceed to use it in a JavaScript project that supports the selected Yarn version.
How to Install Yarn on Windows 10 and Windows 11
On Windows, you can set up Yarn with PowerShell, Command Prompt, or Windows Terminal. The instructions below demonstrate the process in PowerShell.
Install Node.js
Install a Node.js version compatible with your project from the official Node.js website . Once installation is complete, launch PowerShell and verify Node.js and npm:
node --versionnpm --version
If Windows cannot find either command, close and reopen PowerShell. If it still fails, confirm that the Node.js installation directory is included in your PATH environment variable.
Check Corepack
Run:
corepack --version
If Corepack is installed and its version works with your Node.js runtime, continue to the next step. Otherwise, install a supported Corepack release:
npm install -g corepack
Some older Node.js installers for Windows provide Corepack as an optional bundled component. If npm detects an installation conflict, review the existing Node.js installation and, if necessary, modify it to remove the bundled Corepack component before installing a replacement.
Enable Corepack and Configure Yarn
Run:
corepack enablecorepack install -g yarn@stable
Verify the Installation
Run:
yarn --version
If PowerShell displays a version number, Yarn is accessible on your Windows system.
What If PowerShell Blocks Yarn?
Occasionally, PowerShell prevents a
.ps1 script shim from running
because of the current execution policy.
Start by finding the command PowerShell is attempting to execute:
Get-Command yarn
If a Windows .cmd launcher
is available for Yarn, test it with:
yarn.cmd --version
When the .cmd launcher works,
PowerShell's script execution rules may
be causing the problem rather than a
broken Yarn installation.
Security note: Before changing execution policies for the entire computer, consider the possible security risks.
How to Install Yarn on macOS
On macOS, Yarn can be installed through Corepack using the built-in Terminal application.
Check Your Development Environment
Open Terminal and run:
node --versionnpm --version
If Node.js is not available on your Mac, install it using the official Node.js installer or a reliable Node.js version manager.
Check and Install Corepack
Run:
corepack --version
If Corepack is unavailable, install a release that is compatible with your Node.js version:
npm install -g corepack
If npm returns a permissions error, check how Node.js was originally installed. Using a Node.js version manager can reduce write-permission issues when installation directories are protected.
Enable Corepack
Run:
corepack enable
Configure Yarn
Run:
corepack install -g yarn@stable
Then check the version:
yarn --version
What About Homebrew?
Homebrew is a popular package manager for macOS. When Yarn has already been installed through Homebrew, its command executable can interfere with the Yarn shim managed by Corepack.
To find out which Yarn executable your shell is using, run:
command -v yarn
If you plan to manage Yarn primarily through Corepack, inspect your existing Homebrew installation before modifying or removing it. Avoid uninstalling unrelated tools merely to fix a command conflict.
Important: A conflict between Homebrew and Corepack does not always require reinstalling Yarn. Check the active executable and its location before changing the installation.
How to Install Yarn on Linux
The Corepack method can be used on Linux distributions including Ubuntu, Debian, and Fedora, provided a compatible Node.js environment is installed. How you install Node.js may differ depending on your Linux distribution.
Verify Node.js and npm
Open your terminal:
node --versionnpm --version
If Node.js is not available on your system, install a compatible version through an appropriate package repository or a Node.js version manager.
Check Corepack
Run:
corepack --version
If Corepack is not installed, use:
npm install -g corepack
Before installing Corepack, confirm that the selected Corepack release supports your current Node.js version.
Enable Corepack
Run:
corepack enable
Configure Yarn
Run:
corepack install -g yarn@stable
Then verify:
yarn --version
What If Yarn Is Still Not Found?
Check which Yarn executable your shell resolves:
command -v yarn
If the command produces no output, the Yarn command shim may be missing from the directories listed in your PATH.
Also check Corepack:
command -v corepack
Corepack may fail to create Yarn command shims if it is installed in a directory your account cannot write to. Choose a suitable installation method or a writable executable directory instead of changing permissions across the entire system.
Important: Verify your PATH and directory permissions before making changes to a system-wide Node.js or Corepack installation.
How to Install Yarn in an Existing Project
If you're working with a repository that already uses Yarn, it's best to follow the Yarn version specified by that project.
Open the project's
package.json
file. You may find a configuration
like this:
{
"name": "example-project",
"version": "1.0.0",
"private": true,
"packageManager": "[email protected]"
}
This project specifies Yarn 3.6.4.
From the project root, use:
corepack install
This prepares the package manager configured for the project. Then verify:
yarn --version
You can install the project's dependencies with:
yarn install
Following these steps prevents unnecessary changes to the Yarn version required by the project.
Related reading
For more information about lockfiles, dependency resolution, and command options, see our Yarn Install Guide .
How to Set Up Yarn for a New Project
When creating a new application instead of working with an existing repository, you can initialize a new Yarn project.
First, create a new project directory and navigate into it:
mkdir my-yarn-projectcd my-yarn-project
Next, initialize your project using modern Yarn:
yarn init -2
The -2 flag enables Yarn's
modern project initialization process.
It does not necessarily mean that the
project will use exactly Yarn version 2.
After initialization, review the files Yarn created and verify which version has been selected:
yarn --version
To install a project dependency, such as Lodash, use:
yarn add lodash
Yarn will update your project's dependency configuration and install the package according to the selected Yarn version and its installation settings.
Important: If your project requires a specific major Yarn version, configure that version directly instead of depending on the default stable release.
How to Install a Specific Yarn Version
Different projects can require different Yarn releases. For example, an older application may need Yarn 2 or Yarn 3, while a new project may use a newer stable release.
Select Yarn 2
From your project directory:
yarn set version 2.4.3
Yarn 2.4.3 is the final release in the Yarn 2 line. For detailed setup and migration instructions, read How to Install Yarn 2 .
Select Yarn 3
For a project that requires Yarn 3.6.4:
yarn set version 3.6.4
Use the version specified by your project rather than automatically selecting an arbitrary release. Learn more in our Install Yarn 3 Guide .
Select the Current Stable Yarn Release
For a project that should use the latest stable modern Yarn release:
yarn set version stable
Then verify:
yarn --version
Important
Selecting stable can move the project
to a newer major version. It should not be used
as an automatic fix for an existing application
that requires a specific release.
Install Yarn With npm: When Is It Appropriate?
Yarn Classic, also called Yarn 1, can be installed directly through npm. This method is useful for maintaining older applications that require Yarn Classic.
If your application depends on Yarn Classic, you can install Yarn 1 globally with npm:
npm install -g yarn@1
After the installation finishes, verify which Yarn version is available:
yarn --version
The displayed version should start with
1. Unlike Corepack, which
manages different Yarn versions for individual
projects, this method installs a standalone
global Yarn Classic release.
Should You Use npm install -g yarn?
For projects using modern Yarn, the official Yarn documentation recommends Corepack instead of depending on a globally installed Yarn package. Different repositories can require different package manager versions. A single global Yarn installation may cause version conflicts when switching between projects.
If you already use Corepack to manage Yarn, avoid adding a competing global Yarn executable through npm unless you specifically need a separate Yarn Classic installation.
When is this appropriate?
Use npm install -g yarn@1
when you maintain a legacy application
that depends on Yarn Classic and
switching it to modern Yarn through
Corepack is not currently an option.
How to Confirm Yarn Is Installed Correctly
Once installation is complete, Yarn should be accessible from your terminal.
Check the runtime:
node --version
Check Corepack:
corepack --version
Check Yarn:
yarn --version
If you are working on a modern Yarn project,
review the version specified in
package.json.
Make sure the active Yarn version
meets the project's requirements.
You can also inspect the available Yarn commands by opening its help:
yarn --help
Once Yarn is working correctly, you can move on to your project setup. In a new project, add the dependencies you need. In an existing repository, install the dependencies already declared by the application.
Verification complete: Confirm that the command versions work and that Yarn matches your project's configuration before installing packages.
Common Yarn Installation Errors and Fixes
Most Yarn installation problems can be traced to a specific cause. Before reinstalling anything, check your installed versions, project settings, and the error message.
Yarn Command Not Found
Example error:
yarn: command not found
This error often indicates that Yarn's executable or Corepack command shim is missing from your PATH. First, confirm that Corepack is available:
corepack --version
Then try enabling the Yarn command shim:
corepack enable yarn
Verify:
yarn --version
If the command still fails, check which executable your shell is resolving and look for other global Yarn installations that might be causing a conflict.
Corepack Command Not Found
If your terminal cannot find Corepack, the package may not be installed or its executable directory may not be included in PATH.
First check Node.js:
node --version
Check npm:
npm --version
If both tools are working, install a Corepack release compatible with Node.js:
npm install -g corepack
Then confirm the installation:
corepack --version
If Corepack is still not recognized, restart your terminal and review your global npm installation path.
Compatibility note: Node.js 25 and later do not bundle Corepack. Older Node.js versions may require a different Corepack release.
Unsupported Node.js Version
An unsupported engine error can occur when the selected Corepack release requires a different Node.js version. Installing Yarn will not resolve that underlying compatibility problem.
Check your current Node.js version:
node --version
Compare your version with the requirements of the Corepack release you want to use. If necessary, update Node.js to a compatible supported version.
For an older application that cannot upgrade Node.js, select a Corepack release compatible with the application's runtime.
Important: Do not force an incompatible Corepack installation with npm flags. A forced installation may leave your package manager unusable.
Permission Denied
Permission errors may appear when Corepack or npm attempts to create executables in a directory your user account cannot modify.
This issue commonly affects global installations and command shims stored in protected directories.
Check how Node.js and npm were installed. On macOS and Linux, using a Node.js version manager can help you manage packages without changing permissions across system directories.
For existing installations, review the ownership and permissions of the relevant executable location before making changes.
Security note: Avoid running every package installation with administrator privileges or recursively changing folder permissions. Fix the specific installation path issue instead.
Wrong Yarn Version
Some projects require a particular Yarn release. If the terminal uses a different version, package commands or dependency installation may fail.
Open the project's
package.json file and
inspect its packageManager
field.
Check the active Yarn version:
yarn --version
From the project root, prepare the configured package manager:
corepack install
Run the version check again from the same directory. Also inspect competing global Yarn installations if the active version is still incorrect.
Tip: Do not automatically switch an older repository to the latest Yarn release. Use the version required by that project.
Yarn Installation Fails Because of Network Problems
Yarn and Corepack may need to download packages over the internet. Installation can fail if a registry is unreachable or a network request is interrupted.
First, confirm your internet connection is working and check whether the package registry is accessible.
If you use a corporate network, VPN, or proxy, verify the relevant network configuration. Firewall settings may also affect package downloads.
Check the npm registry currently configured:
npm config get registry
Once connectivity and registry access are restored, retry the installation. If the problem persists, review the exact network error message.
Yarn Is Installed but Dependencies Fail
When Yarn itself works but packages cannot be installed, the issue may be related to the project's dependencies rather than Yarn setup.
Common causes include incompatible package versions, project configuration, dependency resolution, or lockfile issues.
From the project directory, run:
yarn install
Carefully review the error reported by Yarn. Check that the project uses the correct Node.js and Yarn versions.
Also inspect the dependency versions
declared in package.json
and any relevant Yarn configuration.
Important: Do not delete the lockfile or replace the project's Yarn version without first understanding the installation error.
Yarn Still Doesn't Work After Reinstallation
Reinstalling Yarn may not solve problems caused by an incorrect PATH, conflicting executables, incompatible Corepack releases, or project-specific configuration.
Start by checking the installed Node.js and Corepack versions:
node --versioncorepack --versionyarn --version
On macOS or Linux, check the active Yarn and Corepack executable locations:
command -v yarncommand -v corepack
On Windows, inspect command resolution with PowerShell:
Get-Command yarnGet-Command corepack
Check for duplicate Yarn installations and confirm that the desired executable appears in your PATH.
For an existing repository, verify that the configured package manager version is compatible with the Node.js runtime.
Recommended approach: Identify and correct the underlying configuration issue before attempting another installation.
Frequently Asked Questions About Installing Yarn
Find answers to common questions about installing Yarn, managing versions, using Corepack, and working with JavaScript projects.
01 How do I install Yarn?
To install Yarn, first make sure Node.js and a compatible version of Corepack are available on your computer. Corepack helps you manage modern Yarn releases and select the correct version for each project.
Enable Corepack's command shims and configure a default stable Yarn release:
corepack enablecorepack install -g yarn@stable
After completing the setup, verify your Yarn installation:
yarn --version
If Corepack is not already installed, you may need to install a version compatible with your Node.js runtime before running these commands. Existing projects may specify a different Yarn release.
02 Do I need Node.js to use Yarn?
Yes. Yarn is a JavaScript package manager designed for the Node.js ecosystem. You need a compatible Node.js runtime before installing and running Yarn.
Node.js provides the runtime environment, while Yarn manages project dependencies, package versions, and scripts. Most standard Node.js installations also include npm, which you can use to install Corepack when necessary.
For existing applications, use the Node.js version required by the project. You can download Node.js from the official Node.js website .
03 Is Yarn free to use?
Yes. Yarn is a free and open-source JavaScript package manager. You can use it to manage dependencies, install packages, and run scripts in personal or commercial projects without paying a Yarn license fee.
Yarn is maintained as an open-source project. Its documentation and source code are publicly available. Individual packages installed through Yarn may have their own licenses, which you should review separately.
04 Can I install Yarn without Corepack?
Yes. Corepack is a recommended version-management approach for modern Yarn projects, but it is not the only possible installation method.
For example, if you are maintaining a legacy application that requires Yarn Classic, you can install Yarn 1 globally using npm:
npm install -g yarn@1
However, using a single global Yarn version can create conflicts when different projects require different Yarn releases. For most modern applications, follow the project's specified package manager version.
05 What is the difference between installing Yarn and yarn install?
Installing Yarn means setting up the Yarn package manager so its commands can run on your computer. This may involve installing Corepack, enabling its command shims, and selecting the appropriate Yarn version.
The yarn install command
performs a different task. It reads
the project's package configuration
and lockfile to install the dependencies
required by that application.
In other words, you first make Yarn
available on your system, and then
use yarn install inside
a project to prepare its dependencies.
06 How do I check my Yarn version?
Open PowerShell, Command Prompt, or a terminal on macOS or Linux and run the following command:
yarn --version
Yarn displays the version currently being used. When you run this command inside a repository configured with Corepack, the result may be the project-specific Yarn release rather than your global default.
If the command is not recognized, check whether Corepack is installed, its Yarn shim is enabled, and the executable is available through PATH.
07 Can I install Yarn 2 and Yarn 3 on the same computer?
Yes. Corepack allows different projects to use different supported Yarn versions on the same computer. You do not need to replace a single global Yarn installation every time you switch between repositories.
For example, one project can declare
[email protected], while another
uses [email protected] in its
packageManager field.
Corepack can select the appropriate
version when you run Yarn commands
inside each project.
This makes it easier to maintain older applications while developing newer projects that use a different Yarn release.
08 Why is Yarn not creating node_modules?
Modern Yarn releases can use
Plug'n'Play (PnP), which is an
alternative to the traditional
node_modules directory.
When Plug'n'Play is enabled, Yarn
may install and resolve dependencies
without creating a standard
node_modules folder.
The installation behavior depends
on your Yarn version and the project's
nodeLinker configuration
in .yarnrc.yml.
If your application requires the
traditional directory structure,
review Yarn's supported
node-modules linker
configuration before changing
the project.
A missing node_modules
folder does not automatically mean
the dependency installation failed.
09 Can I use Yarn and npm together?
Yes. Yarn and npm can both be installed on the same computer, and you can use either tool for projects that support it.
However, it is generally better to use one primary package manager consistently within the same repository. Switching between Yarn and npm can produce different lockfiles and dependency resolutions.
If your project uses Yarn, follow
its yarn.lock file and
packageManager configuration.
If it uses npm, follow its existing
npm configuration and lockfile.
This approach helps reduce unexpected dependency changes when working with other developers or build systems.
10 Should I use the latest Yarn version?
For a new project, using a current, supported stable Yarn release can be a reasonable starting point, provided your development tools and dependencies are compatible.
For an existing application, the latest Yarn release is not always the correct choice. The repository may depend on features, configuration options, or a dependency layout associated with an older Yarn version.
Check the project's
packageManager field
and existing documentation.
Only upgrade to a newer major version
after reviewing compatibility and
testing the project.
Corepack helps you use the release required by each project without forcing every repository to use the same global Yarn version.