Press Ctrl/Cmd + P to print
or save as PDF

4 Basic Ways of Using Yarn On Linux VPS Server

Dependency manager is commonly used for developers to avoid losing time from installing dependencies for their projects. Yarn is a Javascript dependency manager commonly used on VPS and it is created by multiple large corporations such as Facebook, Google, Tilde, and Exponent. The main selling points of this dependency manager are its speed to process dependencies, its security, and its flexibility.

In this tutorial, we will be guiding you on the basic ways of using Yarn on your Linux VPS server.

Creating New Project

In this tutorial, we will be going through the most basic command in Yarn that you will be using for your project. For starters, you will first need to create a new project. To create a new project, use the following command and replace “project_name” with any project name of your preference.

yarn init project_name

After creating a project, a few questions will be asked which will later create a “.json” file where you will be setting your dependencies on. Press Enter for every question for a default Yarn setup.

Adding Dependencies

After the project is created, we may start adding dependencies to it. To add them to your project, use the following line.

yarn add <package>

Alternatively, if you need a specific version of the dependencies for your project, you may use the following line.

yarn add <package>@<version>

Updating Dependencies

If your project has used the older version of the dependencies for a long time, and you need it to be updated, you can update the dependencies using the upgrade option as such.

yarn upgrade <package>

Similar to adding a dependency, if you need to upgrade a package to a specific version, you may specify it this way.

yarn upgrade <package>@<version>

Removing and Installing Dependencies

In this section, you will learn how to remove unwanted dependencies project and install dependencies that had been defined in your “packages.json” file.

To remove the unwanted dependency from your project, use the following command line.

yarn remove <package>

To install all defined dependencies from the “packages.json” file onto your project, you may use one of the two commands listed below.

yarn
yarn install

There are all basics of using Yarn for your projects on your server.