Skip to content
Follow
Ubuntu Linux

How to Install Yarn on Ubuntu Linux?

Richard
Written by
Richard
May 9, 2020 Updated Aug 14, 2026 4 min read
How to Display Seconds on Ubuntu Top Menu Clock
How to Display Seconds on Ubuntu Top Menu Clock

Yarn on Ubuntu Linux is a popular package manager that downloads, updates, and tracks the code libraries your JavaScript projects need to run. It acts as a faster alternative to npm (Node Package Manager), helping you keep your project files organized and working the exact same way on every computer.

Installing Yarn on Ubuntu versions like 22.04 or 24.04 takes just a few minutes using your terminal. Once set up, it saves copies of your downloaded packages in a local cache so you can install them offline or much faster next time.

⚡ Quick Answer

Add the Yarn repository and its GPG key, then install Yarn using apt. Run `sudo apt update`, `sudo apt install curl`, `curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -`, `echo “deb https://dl.yarnpkg.com/debian/ stable main” | sudo tee /etc/apt/sources.list.d/yarn.list`, and finally `sudo apt install yarn`.

How to install and use Yarn on Ubuntu Linux

As described above, Yarn is a fast, reliable, and secure JavaScript dependency manager that automates installing , updating, configuring, and managing npm packages.

Below is how to install it on Ubuntu Linux.

Add Yarn APT Repository

You need to add the Yarn APT repository to your Ubuntu system so it knows where to find Yarn. This step also involves adding the repository’s security key to make sure the packages you download are safe. Running a few commands will get the repository ready for installing Yarn.

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.

🐧Bash / Shell
sudo apt update
sudo apt install curl
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

Next, run the commands below to add the repository

Command Prompt
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

That's all you need to install Yarn.

After that, run the commands below to install Yarn

🐧Bash / Shell
sudo apt update
sudo apt install yarn

If you already have Node.js installed, simply run the commands below to install Yarn, but skip Node.js packages and dependencies.

🐧Bash / Shell
sudo apt install --no-install-recommends yarn

Verify Yarn is Installed

After installing Yarn on Ubuntu, you can easily check if it's working by verifying its version. Simply type `yarn --version` into your terminal. This command will show you the specific version number of Yarn that is now installed on your computer.

💻Code
yarn --version

The output should be something similar to the line below:

💻Code
1.10.1

Now that you have Yarn installed on your Ubuntu system,  here are some of the most common commands you'll need.

You can create a new Yarn project by running the `yarn init` command in your terminal. This command starts the Yarn package manager's initialization process, guiding you through setting up the `package.json` file, which holds information about your project and its dependencies.

💻Code
yarn init myproject

The init script will ask you several questions. You can either answer or press to use the default values.

💻Code
yarn init v1.10.1
question name (richard): 
question version (1.0.0): 
question description: 
question entry point (index.js): 
question repository url: 
question author: 
question license (MIT): 
question private: 
success Saved package.json
Done in 13.40s.

After that, the script will create a basic package.json file containing the information you provided above.

Upgrading dependencies

Once you have Yarn installed on Ubuntu, updating your project's dependencies is straightforward. You can use the `yarn upgrade` command to update everything at once, or you can choose to update a specific package by name or version. If no package name is given, Yarn updates all dependencies.

💻Code
yarn upgrade
yarn upgrade [package_name]
yarn upgrade [package_name]@[version_or_tag]
⚠️Warning
If you do not provide a package name, Yarn will update all the 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.

Do I need npm to install yarn?

It is recommended to install Yarn through the npm package manager, which comes bundled with Node. js when you install it on your system.

What is the yarn install command?

yarn install is used to install all dependencies for a project. This is most commonly used when you have just checked out code for a project, or when another developer on the project has added a new dependency that you need to pick up. If you are used to using npm you might be expecting to use --save or --save-dev .

How do I install yarn software?

Download and Install Yarn Go to https://classic.yarnpkg.com/lang/en/docs/install/#windows-stable and download the Yarn windows installer . msi file and follow the instructions in the Setup Wizard. Open the windows Command Prompt and locate the yarn folder or use this path: C:\Program Files (x86)\Yarn\bin .

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

📚 Related Tutorials

How to Install KDE Desktop on Ubuntu 24.04
Ubuntu Linux How to Install KDE Desktop on Ubuntu 24.04
How to Install GNOME Desktop on Ubuntu 24.04
Ubuntu Linux How to Install GNOME Desktop on Ubuntu 24.04

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *