Yarn, also called “Yet Another Resource Navigator,” is a fast, secure and reliable JavaScript package manager that allows you to automate the installation, configuring, updating, and removing of npm packages. Yarn caches every package it has downloaded, so it never needs to download the same package again.
In this post, we will explain the following:
- Install Yarn using NPM
- Install Yarn from repository NPM
- Install Yarn with Script
Step 1 – Install YARN using NPM
In this section, we will show you how to install Yarn via Node Package Manager.
First, you will need to add the NodeSource repository to your system. You can add it with the following command:
curl --silent --location https://rpm.nodesource.com/setup_22.x | bash -
Once the repository is added, install the Node.js and NPM package using the following command:
dnf install nodejs npm -y
Next, verify the Node.js version with the following command:
node --version
Sample output:
v22.21.0
You can also check the NPM version using the following command:
npm -v
Sample output:
10.9.4
Now, install the Yarn package using the NPM as shown below:
npm install --global yarn
You should get the following output:
npm notice npm notice New major version of npm available! 10.9.4 -> 11.6.2 npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.6.2 npm notice To update run: npm install -g [email protected] npm notice
Next, verify the Yarn version with the following command:
yarn -v
Sample output:
1.22.11
You can uninstall the Yarn package from your system using the following command:
npm uninstall -g yarn
Step 2 – Install YARN with Script
In this section, we will show you how to install Yarn via the Yarn installation script.
You can download and run the Yarn installation script using the following command:
curl -o- -L https://yarnpkg.com/install.sh | bash
Once the Yarn package has been installed, you should get the following output:
> Successfully installed Yarn 1.22.22! Please open another terminal where the `yarn` command will now be available.
Next, activate the system path with the following command:
source ~/.bashrc
Next, verify the Yarn version using the following command:
yarn -v
Sample output:
1.22.22
Conclusion
In the above guide, we explained the two-way to install the Yarn package on RockyLinux 10. You can now use your preferred way to install the Yarn to your system. Get started with Yarn on a dedicated host from Atlantic.Net today!