Install Yarn On Docker

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.

This tutorial contains three ways to install Yarn on CentOS, Redhat, & Fedora system. Use one of the following ways:

1. Install Yarn using NPM

Pretty smooth, just takes a ton of time to install yarn. This should only happen the first time - Docker will cache the layer so future runs shouldn't have to install Yarn again (it'll used the cached version).

  1. The command will install the package and any packages that it depends on, and update the project’s package.json and yarn.lock files. By default, if only the package name is given, Yarn installs the latest version. To install a specific version or tag, use the following syntax: yarn add [email protected] versionortag.
  2. FROM ubuntu RUN apt update RUN apt install -q -y nodejs RUN npm install -g yarn Node from Deb source Similar to above, but instead of getting the Node version supported by APT (e.g. 10 or 12), you get a target version that you specify (like 14 or 16).

Yarn package is available to install with NPM. You can simply run the following command to install Yarn globally. Also, remove -g option to install for the current project only.

Check installed version:

2. Install Yarn using Script


This is the most recommended way for the yarn installation. This downloads the yarn archive and extracts under the .yarn directory at home. The script also set the PATH environment variable.

Using this installation yarn is available for the current user only.

3. Install Yarn using Yum

Yarn packages are also available with yum package manager. You can configure yarn official yum repository using the below command:

Install Yarn On Docker Software

Now run the below command to install it.

Most Viewed Posts