If you’re a JavaScript programmer and looking for an easier dependencies management tool, then Yarn is a tool you should be using. Yarn is a fast, reliable, and secure JavaScript dependency manager that you can use to automate the process of installing, updating, configuring, and managing npm packages. It caches every package it downloads so it never needs to download it again. When you’re done, you’ll be able to easily manage npm packages via the Yarn APT package repository, since Yarn guarantees that an install that worked on one system will work the same way on any other system, it’s a great way to manage npm packages. For more about Yarn, please visit its homepage.
How to install and use Yarn on Ubuntu Linux
As described above, Yarn is a fast, reliable, and secure JavaScript dependency manager that automates the process of installing, updating, configuring, and managing npm packages. Below is how to install it on Ubuntu Linux.
Add Yarn APT Repository
Before installing Yarn, you should first install its package repository. To do that you’ll first need to add the repository’s GPG key to authenticate packages being installed from there. Run the commands below to add the Yarn repository’s GPG key to Ubuntu. Next, run the commands below to add the repository That’s all you need to install Yarn. After that, run the commands below to install Yarn If you already have Node.js installed, simply run the commands below to install Yarn, but skip Node.js packages and dependencies.
Verify Yarn is Installed
To verify if Yarn is installed, run the commands below to print out the version number of Yarn installed on your system. The output should be something similar to the line below: Now that you have Yarn installed on your Ubuntu system, here are some of the most common commands you’ll need. To create a new Yarn project use the yarn init command as shown bellow: The init script will ask you several questions. You can either answer or press to use the default values. After that, the script will create a basic package.json file containing the information you provided above.
Upgrading dependencies
If you want to upgrade dependencies, simply run the commands below for each of the packages and versions you want to upgrade or update. If you do not provide a package name, Yarn will update the entire project dependencies. For more about using Yarn, check this page. Conclusion: This post showed you how to install Yarn on Ubuntu 20.04 | 18.04. If you find any error above, please use the comment form below to report.