In this post, we will explain the following:
- How to install Yarn using NPM
- How to install Yarn from repository NPM
- How to install Yarn using a script
- A server running Oracle Linux 8 on the Atlantic.Net Cloud Platform
- A root password configured on your server
Step 1 – Create Atlantic.Net Cloud Server
First, log in to your Atlantic.Net Cloud Server. Create a new server, choosing Oracle Linux 8 as the operating system with at least 2GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.
Once you are logged in to your server, run the following command to update your base system with the latest available packages.
dnf update -y
Step 2 – Install YARN using npm
First, you will need to install Node.js and npm on your server. First, list all available Node.js versions using the following command:
dnf module list nodejs
You will get the following list:
Now, install Node.js version 16 using the following command:
dnf install @nodejs:16
Once Node.js is installed, verify the Node.js version with the following command:
You can also check the npmversion using the following command:
Now, use npm to install the Yarn package as shown below:
npm install --global yarn
You can verify the Yarn version with the following command:
If you want to uninstall the Yarn package from your system, run the following command:
npm uninstall -g yarn
Step 3 – Install YARN from Yum Repository
By default, the Yarn package is not included in the Oracle Linux default repository, so you will need to add the Yarn repo to your system.
First, create a Yarn repo with the following command:
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | tee /etc/yum.repos.d/yarn.repo
Once the Yarn repo is created, install the Yarn package with the following command:
dnf install yarn -y
Once the Yarn has been installed, activate the Yarn environment variable using the following command:
Next, verify the Yarn version with the following command:
If you want to remove the Yarn package from your system, run the following command:
dnf remove yarn -y
Step 4 – Install YARN with Script
Yarn also provides a bash script that allows you to install Yarn on any Linux operating system. 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:
> GPG signature looks good > Extracting to ~/.yarn... > Adding to $PATH... > We've added the following to your /root/.bashrc > If this isn't the profile of your current shell then please add the following to your correct profile: export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH" > Successfully installed Yarn 1.22.18! Please open another terminal where the `yarn` command will now be available.
Next, activate the system path with the following command:
Next, verify the Yarn version using the following command:
In the above guide, we explained three-way to install the Yarn package on Oracle Linux 8. You can now use your preferred way to install the Yarn on your system. Give it a try on your dedicated server from Atlantic.Net!