How to Install Yarn on Windows

Introduction

Yarn is a package manager developed by Facebook as an alternative to the NPM client. It allows teams to develop JavaScript code and share it through software packages.

Yarn brings a host of improvements compared to NPM, such as higher speed, reliability, and greater compatibility. There are several methods of installing Yarn, from using the MSI installation file to using other package managers and installing it from the Windows PowerShell.

In this tutorial, we will offer a step-by-step process for different methods of installing Yarn on Windows.

How to install Yarn on Windows

Prerequisites

Note: Bare Metal Cloud was build by a DevOps team for DevOps teams. It supports IaC tools and automated server provisioning via API and CLI. Launch a Windows-powered Bare Metal Cloud server and follow this guide to configure Yarn on it.

Get a development sandbox environment for as low as $0.10/hour!

Install Yarn on Windows via MSI Installer

1. Download the Yarn installation file from GitHub.

2. Run the installation file and click Next to proceed.

Start the Yarn installation using the MSI installer

3. Check the box to accept the license agreement and click Next to continue.

Accept the license agreement

4. Select the destination where you want to install Yarn and click Next to proceed.

Select the install destination

5. Click Install to start the installation process.

Start the installation process

6. Once the installation is complete, click Finish to exit the installation wizard.

Click the finish button to exit the Yarn installation

7. Run the following command in the PowerShell to verify the installation:

yarn --version
Verify the installation in the PowerShell

Install Yarn on Windows via Chocolatey Package Manager

Another method is to use the Chocolatey package manager to install Yarn. Using Chocolatey also helps resolve dependencies since it automatically installs Node.js:

1. Open the PowerShell as an administrator.

2. Check the status of the execution policy with:

Get-ExecutionPolicy
Check the status of the execution policy

3. If the execution policy status is Restricted, set it to AllSigned using:

Set-ExecutionPolicy AllSigned

4. When prompted, type Y and press Enter to confirm.

Set the execution policy to AllSigned

5. Install the Chocolatey package manager by using:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

6. Run the following command to install Yarn:

choco install yarn
Install Yarn using Chocolatey

7. Type Y and press Enter when prompted to confirm the install.

8. Restart the PowerShell for the changes to take effect. Verify the installation with:

yarn --version
Verify the installation

Install Yarn on Windows via Scoop CLI

The Scoop CLI (command line installer) works in a similar way to Chocolatey, with the main difference being that Scoop does not automatically install Node.js.

1. Open the PowerShell as an administrator.

2. Set the execution policy to allow PowerShell to run local scripts:

set-executionpolicy remotesigned -scope currentuser

3. When prompted, type Y and press Enter to confirm.

Set the execution policy

4. Install Scoop CLI by using:

iwr -useb get.scoop.sh | iex
Install Scoop CLI in the PowerShell

5. Start the Yarn installation with:

scoop install yarn
Install Yarn using Scoop CLI

6. Verify the installation using:

yarn --version
Verify the installation

Install Yarn on Windows via NPM

NPM (Node Package Manager) is a package manager included with the Node.js installation. It is used for developing and sharing JavaScript code, but it also provides another method of installing Yarn:

1. Open the PowerShell as an administrator.

2. Install Yarn by running the following command:

npm install --global yarn
Install Yarn using NPM

3. Verify the Yarn installation with:

yarn --version
Verify the installation

Conclusion

After following this tutorial, you should have a copy of Yarn installed and ready to use.

If you are interested in using Yarn on a Linux system, check out our guide to installing Yarn on Ubuntu 18.04.

原创文章,作者:3628473679,如若转载,请注明出处:https://blog.ytso.com/224158.html

(0)
上一篇 2022年1月7日
下一篇 2022年1月7日

相关推荐

发表回复

登录后才能评论