
Managing project dependencies efficiently is crucial for modern web development and software projects. Yarn is a popular package manager that offers speed, reliability, and security features, often preferred over npm for certain workflows. If you’re working on Debian 10 Buster and need to install Yarn, this guide will walk you through the process step-by-step.
Before you begin, it’s important to note that Yarn requires Node.js to be installed on your system. While Debian’s default repositories include Node.js, it’s often an older version. For the best compatibility and access to recent features, it’s recommended to install Node.js from the official NodeSource repositories. If you haven’t already installed Node.js from NodeSource, you should do that first.
Once Node.js is ready, you can proceed with installing Yarn using its official repository. This method ensures you get a current version of Yarn and can easily update it later.
Here are the steps to install Yarn on Debian 10:
Add the GPG key for the Yarn repository. This key is used to verify the authenticity of the packages you download. Open your terminal and run the following command:
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
This command downloads the key and adds it to your system’s list of trusted keys.
Add the Yarn repository to your system’s software sources. This tells your package manager where to find Yarn packages. Execute this command in your terminal:
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
This creates a new file in your
sources.list.d
directory pointing to the Yarn repository.Update your package list. After adding a new repository, you need to refresh your system’s package index so it knows about the available packages from the new source. Use this command:
sudo apt update
Install Yarn. Now that your system knows where to find Yarn, you can install it using the
apt
package manager. Run the following command:sudo apt install yarn
This command will download and install Yarn, along with any necessary dependencies (like Node.js if you didn’t install it separately, though the NodeSource method is still recommended).
Verify the installation. To confirm that Yarn was installed correctly and is accessible in your system’s PATH, you can check its version. Execute:
bash
yarn --version
If the installation was successful, this command will output the installed Yarn version number.
Congratulations! You have successfully installed Yarn on your Debian 10 Buster system using the recommended method from the official repository. You can now use Yarn to manage dependencies for your Node.js projects, leveraging its speed, reliability, and features like offline caching and deterministic installs.
Source: https://kifarunix.com/install-yarn-on-debian-10/