AMP AMP

How to install Yarn Package Manager on Oracle Linux 9.2

To Install Yarn Package Manager On Oracle Linux 9.2

Introduction:

YARN, short for Yet Another Resource Navigator, is a fast, stable, and reliable Javascript package manager that is compatible with npm ( Node Package Manager). Yarn helps with the management of npm packages which includes installation, updating, configuration, and removal of packages.

Installation Steps:

Step 1: Check the version of the OS by using the below command.

[root@Linuxhelp ~]# cat /etc/os-release
NAME="Oracle Linux Server"
VERSION="9.2"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="9.2"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Oracle Linux Server 9.2"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:9:2:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://github.com/oracle/oracle-linux"
ORACLE_BUGZILLA_PRODUCT="Oracle Linux 9"
ORACLE_BUGZILLA_PRODUCT_VERSION=9.2
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=9.2

Step 2: Add the NodeSource repository by using the below command.

[root@linuxhelp ~]# curl -sL https://rpm.nodesource.com/setup_16.x | bash -

================================================================================
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
================================================================================
SCRIPT DEPRECATION WARNING                    

This script, located at https://rpm.nodesource.com/setup_X, used to
  install Node.js is deprecated now and will eventually be made inactive.

  Please visit the NodeSource distributions Github and follow the
  instructions to migrate your repo.
  https://github.com/nodesource/distributions

  The NodeSource Node.js Linux distributions GitHub repository contains
  information about which versions of Node.js and which Linux distributions
  are supported and how to install it.
  https://github.com/nodesource/distributions

                          SCRIPT DEPRECATION WARNING

================================================================================
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
================================================================================

TO AVOID THIS WAIT MIGRATE THE SCRIPT
Continuing in 60 seconds (press Ctrl-C to abort) ...

## Installing the NodeSource Node.js 16.x repo...
## Inspecting system...
+ uname -m
redhat-release-9.2-0.13.0.1.el9.x86_64
redhat-release-9.2-0.13.0.1.el9.x86_64
exec redhat-release
Release package: redhat-release-9.2-0.13.0.1.el9.x86_64
redhat-release-9.2-0.13.0.1.el9.x86_64

## Confirming "el9-x86_64" is supported...

+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_16.x/el/9/x86_64/nodesource-release-el9-1.noarch.rpm'

## Downloading release setup RPM...

+ mktemp
+ curl -sL -o '/tmp/tmp.ZrQXj9XjOo' 'https://rpm.nodesource.com/pub_16.x/el/9/x86_64/nodesource-release-el9-1.noarch.rpm'

## Installing release setup RPM...

+ rpm -i --nosignature --force '/tmp/tmp.ZrQXj9XjOo'

## Cleaning up...

+ rm -f '/tmp/tmp.ZrQXj9XjOo'

## Checking for existing installations...

+ rpm -qa 'node|npm' | grep -v nodesource

## Run `sudo yum install -y nodejs` to install Node.js 16.x and npm.
## You may run dnf if yum is not available:
     sudo dnf install -y nodejs
## You may also need development tools to build native addons:
     sudo yum install gcc-c++ make
## To install the Yarn package manager, run:
     curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
     sudo yum install yarn

Step 3: Next, install the latest Node.js version by using the below command.

[root@linuxhelp ~]# dnf install nodejs
Node.js Packages for Enterprise Linux 9 - x86_6 564 kB/s | 280 kB     00:00    
Oracle Linux 9 BaseOS Latest (x86_64)            25 kB/s | 3.6 kB     00:00    
Oracle Linux 9 BaseOS Latest (x86_64)            17 MB/s |  17 MB     00:00    
Oracle Linux 9 Application Stream Packages (x86  28 kB/s | 3.9 kB     00:00    
Oracle Linux 9 Application Stream Packages (x86  20 MB/s |  26 MB     00:01    
Oracle Linux 9 UEK Release 7 (x86_64)            20 kB/s | 3.0 kB     00:00    
Oracle Linux 9 UEK Release 7 (x86_64)            19 MB/s |  24 MB     00:01    
Dependencies resolved.
================================================================================
 Package      Architecture Version                       Repository        Size
================================================================================
Installing:
 nodejs       x86_64       2:16.20.2-1nodesource         nodesource        32 M

Transaction Summary
================================================================================
Install  1 Package

Total download size: 32 M
Installed size: 89 M
Is this ok [y/N]: y
Downloading Packages:
nodejs-16.20.2-1nodesource.x86_64.rpm            26 MB/s |  32 MB     00:01    
--------------------------------------------------------------------------------
Total                                            26 MB/s |  32 MB     00:01     
Node.js Packages for Enterprise Linux 9 - x86_6 1.4 MB/s | 1.6 kB     00:00    
Importing GPG key 0x34FA74DD:
 Userid     : "NodeSource <gpg-rpm@nodesource.com>"
 Fingerprint: 2E55 207A 95D9 944B 0CC9 3261 5DDB E8D4 34FA 74DD
 From       : /etc/pki/rpm-gpg/NODESOURCE-GPG-SIGNING-KEY-EL
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1 
  Running scriptlet: nodejs-2:16.20.2-1nodesource.x86_64                    1/1 
  Installing       : nodejs-2:16.20.2-1nodesource.x86_64                    1/1 
  Running scriptlet: nodejs-2:16.20.2-1nodesource.x86_64                    1/1 
  Verifying        : nodejs-2:16.20.2-1nodesource.x86_64                    1/1 

Installed:
  nodejs-2:16.20.2-1nodesource.x86_64                                           

Complete!

Step 4: Verify the installed Node.js version by using the below command.

[root@Linuxhelp ~]# node -v
v16.20.2

Step 5: To verify the NPM version, run the below command.

[root@Linuxhelp ~]# npm -v
8.19.4

Step 6: By default, Yarn is not available on Rocky Linux 9 base repository. Now run the below command to add the Yarn repository to your system.

[root@linuxhelp ~]# curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
[yarn]
name=Yarn Repository
baseurl=https://dl.yarnpkg.com/rpm/
enabled=1
gpgcheck=1
gpgkey=https://dl.yarnpkg.com/rpm/pubkey.gpg

Step 7: After the repository has been successfully added, we can install Yarn by running the below command.

[root@linuxhelp ~]# dnf install yarn
Yarn Repository                                 242 kB/s | 316 kB     00:01    
Last metadata expiration check: 0:00:01 ago on Wednesday 29 November 2023 02:24:58 AM.
Dependencies resolved.
================================================================================
 Package         Architecture      Version                Repository       Size
================================================================================
Installing:
 yarn            noarch            1.22.19-1              yarn            1.2 M

Transaction Summary
================================================================================
Install  1 Package
Total download size: 1.2 M
Installed size: 5.1 M
Is this ok [y/N]: y
Downloading Packages:
yarn-1.22.19-1.noarch.rpm                       2.5 MB/s | 1.2 MB     00:00    
--------------------------------------------------------------------------------
Total                                           2.4 MB/s | 1.2 MB     00:00     
Yarn Repository                                 4.0 kB/s | 1.6 kB     00:00    
Importing GPG key 0x6963F07F:
 Userid     : "Yarn RPM Packaging <yarn@dan.cx>"
 Fingerprint: 9A6F 73F3 4BEB 7473 4D8C 6914 9CBB B558 6963 F07F
 From       : https://dl.yarnpkg.com/rpm/pubkey.gpg
Is this ok [y/N]: y
Key imported successfully
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1 
  Installing       : yarn-1.22.19-1.noarch                                  1/1 
  Verifying        : yarn-1.22.19-1.noarch                                  1/1 

Installed:
  yarn-1.22.19-1.noarch                                                         

Complete!

Step 8: Now we can check the Yarn version by using the below command.

[root@Linuxhelp ~]# yarn -v
1.22.19

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to install Yarn Package Manager on Oracle Linux 9.2. Your feedback is much welcome.

FAQ
Q
How do I remove a package with Yarn?
A
To remove a package from your project, you can run the following command:
yarn remove
Q
How do I create a new project with Yarn?
A
To create a new project, navigate to the desired directory in your terminal and run:
yarn init
Q
How do I use Yarn to install packages?
A
Once you have installed Yarn, you can use it to install packages by running the following command:
yarn add
Q
How do I check if Yarn is installed?
A
After installing Yarn, you can check the version to confirm the installation. Open a terminal and run: yarn –version.
Q
What is Yarn Package Manager?
A
Yarn is a JavaScript package manager that serves as an alternative to npm (Node Package Manager). It was developed by Facebook, Google, Exponent, and Tilde. Yarn is designed to be fast, reliable, and secure when installing and managing JavaScript packages.