Installing Yarn on Windows 11 (MDX)
This guide provides step-by-step instructions for installing Yarn package manager on Windows 11.
Prerequisites
Section titled “Prerequisites”- Windows 11 operating system
- Node.js installed (Yarn requires Node.js to function properly)
Installation Methods
Section titled “Installation Methods”There are multiple ways to install Yarn on Windows 11. Choose the method that works best for your setup.
Method 1: Installing via npm (Recommended)
Section titled “Method 1: Installing via npm (Recommended)”If you already have Node.js installed, this is the simplest approach:
- Open Command Prompt or PowerShell as Administrator
- Run the following command:
npm install --global yarn
- Verify the installation:
yarn --version
Method 2: Installing via the MSI installer
Section titled “Method 2: Installing via the MSI installer”- Visit the official Yarn website: https://classic.yarnpkg.com/en/docs/install/#windows-stable
- Download the Yarn installer (.msi file)
- Run the downloaded MSI file and follow the installation wizard
- Restart your command prompt or terminal
- Verify the installation:
yarn --version
Method 3: Installing via Chocolatey
Section titled “Method 3: Installing via Chocolatey”If you use Chocolatey package manager:
- Open Command Prompt or PowerShell as Administrator
- Run the following command:
choco install yarn
- Verify the installation:
yarn --version
Method 4: Installing via Scoop
Section titled “Method 4: Installing via Scoop”If you use Scoop package manager:
- Open Command Prompt or PowerShell as Administrator
- Run the following command:
scoop install yarn
- Verify the installation:
yarn --version
Configuring Yarn
Section titled “Configuring Yarn”After installation, you may want to configure Yarn:
- Set up your npm registry (if using a custom one):
yarn config set registry https://registry.npmjs.org/
- Initialize a new project:
yarn init
Troubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”-
“‘yarn’ is not recognized as an internal or external command”
- Restart your terminal/command prompt
- Ensure Yarn was added to your PATH during installation
- Try reinstalling Yarn
-
Permission issues
- Make sure you’re running the installation as Administrator
-
Node.js not found
- Install Node.js before installing Yarn
- Verify Node.js installation with
Terminal window node --version
Useful Commands
Section titled “Useful Commands”Once Yarn is installed, you can use these common commands:
- Initialize a new project:
Terminal window yarn init - Add a dependency:
Terminal window yarn add [package] - Add a dev dependency:
Terminal window yarn add [package] --dev - Install all dependencies:
or
Terminal window yarnTerminal window yarn install - Upgrade a package:
Terminal window yarn upgrade [package] - Remove a package:
Terminal window yarn remove [package]
Additional Resources
Section titled “Additional Resources”License
Section titled “License”This installation guide is provided under the MIT License.