Raspberry Pi

How to Install Yarn on Raspberry Pi

Yarn allows packages to be installed via the npm registry and is a Node.js package manager. Yarn is used as an alternative to NPM and is compatible with it. It has better performance compared to NPM since it can perform parallel installation and provides a secure environment for installing packages in the system.

Follow this guide to install Yarn package manager on Raspberry Pi system.

Installation of Yarn on Raspberry Pi

Follow the instructions below to install Yarn on a Raspberry Pi:

Step 1: Install Node.js initially on the Raspberry Pi using the command line:

$ sudo apt install nodejs -y

Step 2: Add the GPG key to your list of trusted keys by downloading it on Raspberry Pi through the following command:

$ curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

Step 3: Add Yarn repository to Raspberry Pi source list through the following command:

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

Step 4: To ensure that the Yarn repository is added to the list successfully, update the Raspberry Pi repository using the command below:

$ sudo apt update

Step 5: Now install Yarn on Raspberry Pi using the following command:

$ sudo apt install yarn -y

Step 6: After the installation is finished, verify the Yarn version through the following command:

$ yarn --version

Test Yarn on Raspberry Pi

To ensure Yarn is running on Raspberry Pi, follow the below-given syntax to download any package through Yarn.

$ yarn add <package_name>

Remove Yarn from Raspberry Pi

If you wish to entirely remove Yarn and associated dependencies from Raspberry Pi, use the following command:

$ sudo apt purge --autoremove -y yarn

Conclusion

Yarn is a Node.js package manager that efficiently downloads the packages on the system. You can easily install this package manager on Raspberry Pi by adding the source repository into the Raspberry Pi repository list. Then update the repository and install the Yarn package manager through the “apt” command. However, you must also ensure installing Node.js on Raspberry Pi using the above-mentioned guidelines.

About the author

Hiba Shafqat

I am a Computer Science student and a committed technical writer by choice. It is a great pleasure to share my knowledge with the world in which I have academic expertise.