How to Install Yarn on Linux and macOS

January 24, 2023 / How-to Guide

Yarn stands for “Yet Another Resource Negotiator”, commonly used on VPS, and improves the workflow and performance of large codebases.

In this guide, we have explained how to install Yarn on Linux and macOS.

You can use npm or cURL to install Yarn on Linux VPS and macOS. However, it is important to have Node.js and npm ready before the installation process.

Yarn Install on Linux and macOS using “npm”:

  1. Connect to your server using SSH by opening the Terminal.
  2. To install Yarn, execute the following command:
    sudo npm install –global yarn
  3. To enable Yarn commands after installation again open the Terminal. To know whether Yarn is installed effectively check the version using the command:
    yarn –version

Install yarn using “cURL”:

  1. Open the Terminal and connect to the server using SSH.
  2. Execute the following command to install Yarn:
    curl -o- -L https://yarnpkg.com/install.sh | bash
  3. To verify the status of the installation, type the following command:
    yarn –version

Yarn Installation using cURL on Debian:

  1. Connect the server via SSH, opening the terminal.
  2. To add the GPG key and to know whether the downloaded packages are relevant, execute the following command:
    curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add –
  3. Entering the command below will add the Yarn APT to the Debian package repository:
    echo “deb https://dl.yarnpkg.com/debian/ stable main” | sudo tee /etc/apt/sources.list.d/yarn.list
  4. Update the package list once the repository has been added by entering this command and clicking Enter.
    sudo apt update
  5. Now, to install Yarn, execute the following command:
    sudo apt install yarn
  6. To check whether the installation was completed successfully, enter the command given below:
    yarn –version

Install Yarn using cURL on CentOS:

  1. Connect the server via SSH, opening the terminal.
  2. To add a yarn repository to the system, execute the following command:
    $ curl –silent –location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
  3. To import the repository’s GPG key, execute the below command:
    sudo rpm –import https://dl.yarnpkg.com/rpm/pubkey.gpg
  4. To install Yarn, execute the following command:
    sudo dnf install yarn
  5. To verify the installation, run the below command:
    yarn –version

This way you can install Yarn on Linux and macOS.

Hope you liked our article. For more information, do visit our KB section regularly.

Also Read:  How to Upgrade Yarn on Linux

Dominos Search