The yarn is an advanced package management software for Node.js applications. It is a fast, secure, and reliable alternative that any other Nodejs package manager’s. I have installed latest Node.js on Ubuntu and Debian systems.
This tutorial contains three methods to install Yarn on Ubuntu, Debian, and LinuxMint systems. Use one of the following methods:
Method 1 – Install Yarn using NPM
Yarn package is available to install with NPM. You can simply use npm command as following to install Yarn globally. To install yarn for current project only just remove -g option from command.
sudo npm install yarn -g
Method 2 – Install Yarn using Script
Yarn also provides a shell script for installation. This is the most recommended way to install Yarn on a Linux system. This script downloads the yarn archive and extracts under the .yarn directory under your home directory. Also, set the PATH environment variable.
curl -o- -L https://yarnpkg.com/install.sh | bash
As this installation put all files under users home directory, So its available for current user only.
Method 3 – Install Yarn using Apt-get
The Yarn team also provides an Apt repository to install yarn on Debian machine. Run the following commands to import gpg key and configure yarn apt repository.
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
Now type following commands to install yarn on Ubuntu Debian and Linux.
sudo apt-get update && sudo apt-get install yarn