• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Install Yarn on Debian 9

Written by Admin, Updated On July 18, 2019
debian, nodejs, npm, yarn
How to Install Yarn on Debian 9

Yarn is a package management tool for Javascript which mostly used for Node.js applications. Yarn is compatible with npm used for installing, configuring, updating and removing npm packages. It is designed to fix npm problems like speeding up installation process, network connectivity issues, etc. In this tutorial, you will learn how to install Yarn on Debian 9 system.

Prerequisites#

You should have logged in on Debian system with non-root user with sudo privileges.

Install Yarn on Debian#

First of all you need to add and enable Yarn repository to your system. After that you can install Yarn.

You can import Yarn repository’s GPG key using below curl command:

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

After importing key add Yarn APT repository using following command:

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

Now you should update the package manager index list and then install Yarn by typing below command:

sudo apt update
sudo apt install yarn

With this command, Node.js will install to your system if already not installed. If you don’t want to install it then you can skip by using below command:

sudo apt install --no-install-recommends yarn

You can verify the installation of yarn by issuing below command:

yarn --version

It should show like as below:

Output
1.13.0

Use of Yarn#

Create a new Project#

You can create a new project using yarn init command as given below:

yarn init new_yarn_project

It will be prompted to you few questions. You can provide information if you want otherwise you can skip by just hitting Enter key for all the questions.

yarn init v1.16.0
question name (tecnstuff): TecNStuff
question version (1.0.0): 0.0.1
question description: Install Yarn
question entry point (index.js):
question repository url:
question author: TecNStuff
question license (MIT):
question private:
success Saved package.json
Done in 96.72s.
yarn init v1.16.0
question name (tecnstuff): TecNStuff
question version (1.0.0): 0.0.1
question description: Install Yarn
question entry point (index.js):
question repository url:
question author: TecNStuff
question license (MIT):
question private:
success Saved package.json
Done in 96.72s.

Once all the questions are completed then it will create a package.json file with the information which you provided. You also can make changes manually to that file.

Install All Dependencies#

To install all project dependencies that are given in the package.json file run:

yarn install

or you can run just yarn as below:

yarn

Adding dependency#

When you have requirement to install another package in your project then you need to add it to the project dependencies. Below is the basic syntax to add dependency:

yarn add [package_name]

This command will update the package.json file yarn.lock file. When you want specific version of any package then you can followed by version number as following:

yarn add [package_name]@[version_or_tag]

Upgrading dependency#

You can upgrade a dependency using any one of the following command:

yarn upgrade [package_name]

or

yarn upgrade [package_name]@[version_or_tag]

It will update specific package and make changes in package.json and yarn.lock file.

Removing dependency#

To remove a dependency using yarn use below command:

yarn remove [package_name]

Same as add and update command this will also update the project’s package.json and yarn.lock files.

Conclusion#

Here, we described how you how to install yarn on Debian 9 machine. You can get more details about yarn at Yarn Documentation page.

If you have any query or suggestion you can comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Install Go on Ubuntu 18.04
Next Article   How to Install Java on Ubuntu 18.04

Related Posts

  • How to Install WordPress with Nginx on Debian 11

    How to Install WordPress with Nginx on Debian 11

    March 22, 2023
  • How to Install and Use Docker on Debian 11

    How to Install and Use Docker on Debian 11

    March 10, 2023
  • How to Install MariaDB on Debian 11 Bullseye

    How to Install MariaDB on Debian 11 Bullseye

    March 8, 2023

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook