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.
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>
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.
There are all basics of using Yarn for your projects on your server.