×


Steps to install Yarn on Windows

Need to install Yarn on Windows 10 computer?

This guide is for you.


Yarn is a fast, reliable, and secure JavaScript dependency manager that you automate the process of installing, updating, configuring, and managing npm packages.

Yarn can be installed on Windows via MSI Installation, Chocolatey Installation, and Scoop Installation methods.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform Software installation tasks.

In this context, we shall look into the steps to install Yarn.


How to install Yarn on Windows ?

Yarn is an alternative npm-client that allows us to share code with other developers around the world and use solutions from other developers.

The package contains a .package.json file that describes the contents, as well as all the associated distributed code. Let us now discuss the steps to install Yarn.


1. Install Node.js

Before installing Yarn, we need to install Node.js must. We can verify the presence of node.js on our system using the Windows terminal or PowerShell.

First, open the terminal by pressing the Win+R buttons and then enter cmd. Then, using the command line, we can verify if Node.js is installed with the command:

C:\Windows\system32>node --version

‘node’ is not recognized as an internal or external command, operable program or batch file.

C:\Windows\system32>

To install node.js, we can download the installer from the main node.js website. Now run the installer and accept the license agreement.

Then, leave all the defaults set and click Next to install node.js. Finally, click on Finish, to complete the installation.


2. Yarn Installation

Now that have installed node.js in the system, the next step is to install Yarn. There are several different methods to install Yarn in Windows. 

Some of them include:

i. MSI Installation

ii. Chocolatey Installation

iii. Scoop Installation

 

i. MSI Installation

The first method we will use to install Yarn is to Download the Yarn .msi installer from the official Yarn website  and install it on the local computer.

Next, we will run the .msi installer and accept the license agreement. Now, click Install and finally, click on the Finish button.

Then, we can verify Yarn was installed using the following CLI commands:

C:\Windows\system32>yarn --version
1.22.4

ii. Chocolatey Installation

Another way to install Yarn is by using the Chocolatey package manager for Windows. This method is convenient because Chocolatey will determine whether node.js is already installed and if not, it will automatically install it for us. Steps to perform this is available in the official site here .

Once Chocolatey is set up, we can install Yarn using the following command.

C:\Windows\system32>choco install yarn

Finally, we can verify our installation of yarn using the following command.

C:\Windows\system32>yarn --version
1.22.4

iii. Scoop Installation

The third method of installing Yarn is by using the Scoop command-line installer for Windows. Scoop has functionality that is similar to Chocolatey. However, the difference is that Chocolatey will install node.js if we do not already have it but scoop will not. The scoop can be installed using the information found on the scoop website.

To install node.js using scoop, run the following command.

scoop install nodejs

Next, we can install yarn using this command.

scoop install yarn

Common Yarn Commands

Let us now have a look at some of the basic Yarn commands:

To review the yarn command – yarn help

Start a New Project – yarn init

Install all the dependencies – yarn or yarn install

Add a dependency to a project – yarn add [package] or yarn add [package]@[version] or yarn add [package]@[tag]

Remove an existing dependency – yarn remove [package]

Upgrade Yarn to the latest version – yarn set version latest or yarn set version from sources


To add dependencies to a specific category, use the following commands:

Dev Dependencies – yarn add [package] –dev

Peer Dependencies – yarn add [package] –peer

Optional Dependencies – yarn add [package] –optimal

 

Upgrade a Dependency

To upgrade an existing dependency, we can use the yarn up command:

yarn up [packagename]
yarn up [packagename]@[version]
yarn up [packagename]@[tag]

[Need urgent assistance to install Yarn on Windows? – We're available 24*7. ]


Conclusion

This article will guide you on steps to install #Yarn in Windows via #MSI Installation, Chocolatey Installation, and Scoop Installation. msi file that when run will walk you through installing Yarn on Windows. If you use the installer you will first need to install Node. js.

Yarn global install locations:

1. On #Windows %LOCALAPPDATA%\Yarn\config\global for example: C:\Users\username\AppData\Local\Yarn\config\global.

2. On #OSX and non-root Linux  ~/.config/yarn/global.

3. On #Linux if logged in as root /usr/local/share/.config/yarn/global.

yarn install is used to install all dependencies for a project. This is most commonly used when you have just checked out code for a project, or when another developer on the #project has added a new dependency that you need to pick up.