Yarn is a command-line tool used in JavaScript applications to manage dependencies. It's comparable to npm (Node Package Manager) but has some extra capabilities, including quicker and more reliable dependency management, offline installation, and job parallelization.
The yarn command is the primary method of interacting with the Yarn tool. It may be used for several activities.
Let's look at how to install yarn on various operating systems.
Windows
You must have Node.js installed on your PC before installing Yarn on Windows. Node.js may be downloaded and installed from their official website.
Installation
Step 1: Yarn may be installed on Windows using Chocolatey, a popular package management. The steps are as follows:
Step 2: Chocolatey may be installed by following the directions on the official website: ttps://chocolatey.org/install
Step 3: After installing Chocolatey, launch Command Prompt or PowerShell and run the following command to install Yarn:
choco install yarn
Step 4: When the installation is complete, run the following command to ensure that Yarn is installed:
yarn --version
Linux
You must have Node.js installed on your PC before installing Yarn on Linux. Node.js may be downloaded and installed from their official website.
Installation
The instructions for installing Yarn on Linux differ based on the distribution. On the other hand, the official Yarn website gives thorough instructions for installing Yarn on several Linux variants. The following are the steps to install Yarn on Ubuntu:
Step 1: Use the following command to add the Yarn repository to your system:
# curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
# echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
Step 2: Use the following command to update the package list and install Yarn:
# sudo apt-get update && sudo apt-get install yarn
Step 3: When the installation is complete, run the following command to ensure that Yarn is installed:
# yarn --version
These are the complete instructions for installing Yarn on various operating systems.
macOS
You must have Node.js installed on your PC before installing Yarn on macOS. Node.js may be downloaded and installed from their official website.
Installation
Step 1: Yarn may be installed on macOS using Homebrew, a popular package manager for the operating system. The steps are as follows:
Step 2: Open the Terminal app and type the following command to install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Step 3: After installing Homebrew, use the following command to install Yarn:
brew install yarn
Step 4: When the installation is complete, run the following command to ensure that Yarn is installed:
yarn --version
That's all.