Install Yarn on Ubuntu 20.04

Install Yarn on Ubuntu 20.04

Yarn is a package manager for Node.js that enables to install various packages from the npm registry. Yarn can be used as alternative for npm. Yarn can use the same package.json format.

This tutorial shows how to install Yarn on Ubuntu 20.04.

Install Yarn

Download and add GPG key to the list of trusted keys:

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

Add the Yarn repository:

echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

Update the package lists:

sudo apt update

If you have Node.js already installed in your machine, then run the following command to install Yarn only:

sudo apt install --no-install-recommends -y yarn

If Node.js is not installed, then you can install Yarn and Node.js with command:

sudo apt install -y yarn

After installation is finished, we can check Yarn version:

yarn --version

Uninstall Yarn

If you want to completely remove Yarn and related dependencies, execute the following command:

sudo apt purge --autoremove -y yarn

Remove GPG key and repository:

sudo apt-key del 86E50310
sudo rm -rf /etc/apt/sources.list.d/yarn.list

Leave a Comment

Cancel reply

Your email address will not be published.