Yarn is an npm-compatible JavaScript package manager that automates the installation, updating, managing, and uninstalling procedure of npm packages. This application manager assists in caching every downloaded package and parallelizing processes to speed up the installation process. Whether you are a business user working on one-shot projects or a hobbyist, Yarn got you covered!
This write-up will discuss the method to install Yarn on Ubuntu 22.04. So, letβs start!
How to Install Yarn on Ubuntu 22.04
To install Yarn on Ubuntu 22.04, you must follow the below-given step-by-step instructions.
Step 1: Update system repositories
Press βCTRL+ALT+Tβ to open the terminal of the Ubuntu 22.04 and run the below-given command to update system repositories:
Step 2: Install CURL on Ubuntu 22.04
After updating the Ubuntu 22.04 system repositories, execute the following command for CURL installation:
The given error-free output signifies that we have successfully installed CURL on our system:
Step 3: Import Yarn GPG key
In the next step, utilize the βcurlβ command for importing the Yarn GPG key to Ubuntu system repositories:
Step 4: Enable Yarn repository
After importing the GPG key, you have to enable the Yarn repository on your Ubuntu 22.04 system. For this purpose, write out the following command in the terminal:
Step 5: Install Yarn on Ubuntu 22.04
If you have carefully followed the previous steps, then at this point, your Ubuntu 22.04 system is all ready for Yarn installation. To do so, execute the below-given command:
Enter βyβ to permit the installation process to continue and wait for a few minutes:
Step 6: Check Yarn version
To verify if Yarn is successfully installed or not, then check its installed version on your Ubuntu 22.04 system:
As you can see that currently Yarn version β0.32+gitβ is installed on our system:
How to upgrade Yarn on Ubuntu 22.04
Want to upgrade Yarn to the latest version? If yes, then first install βnpmβ on your system; if you do not have it already:
Then, download the βYarnβ tarball and install its latest version by writing out the following command in the Ubuntu 22.04 terminal:
As you can see from the highlighted part of the below output, Yarn installed on our system is upgraded to the latest β1.22.18β version:
Lastly, execute the βyarnβ command with the β–versionβ option to confirm that Yarn is upgraded to the latest version:
We have compiled the simplest method to install Yarn on Ubuntu 22.04. Moreover, the procedure to upgrade the current Yarn to the latest version is also provided to you.
Conclusion
To install Yarn on Ubuntu 22.04, first of all, install CURL with the β$ sudo apt install curlβ command. After doing so, import the Yarn GPG key and enable its repository on your system. Then, execute the β$ sudo apt install yarnβ for Yarn installation. You can also utilize the β$ sudo curl –compressed -o- -L https://yarnpkg.com/install.sh | bashβ to upgrade Yarn. This write-up discussed the method to install Yarn on Ubuntu 22.04.