Yarn is a package manager made by Facebook for the system to be created. Never heard of a package manager? A package manager is a package of installing, updating, configuring and removing software. So if you install using a package manager, you don't need to configure it separately. You only need to enter certain commands such as add or install. How to install Yarn on Hosting is also very easy for beginners.
What is Yarn?
What is the difference between Yarn and npm?
Installing the Package Manager
You have to install npm sequentially. This means that you cannot take the next step if the previous step has not been completed. Unlike Yarn, you can do several installations at one time. Of course, this is more flexible and faster.
Yarn is always faster when compared to npm which has a version below 5.0. Quoted from Scott Logic's experiment , Yarn is still faster when compared to npm 4 and 5.
Yarn is considered safer and more secure than npm. This is because Yarn only runs packages from the yarn.lock or package.json file. Meanwhile, npm runs system code from various dependencies. In addition, Yarn also provides a checksum before installing.
Yarn has a yarn.lock file to make it easier for users to add new modules.
How to Install Yarn on Hosting
You can follow step by step how to install Yarn on the following Hosting.
1. SSH access to Hosting
To install Yarn, you need access to the Hosting server via SSH using the Terminal or PuTTy Software. For you Linux or Mac users, you can use the terminal. For you Windows users, you can use PuTTy software. If you don't know how, please read the SSH Access Guide . Please write the following command in Terminal / PuTTy. Keep in mind that SSH can only be done at a minimum of Super Hosting Packages .
ssh username @ controlpanelURL â€“p 64000
2. Install Yarn on Hosting
To install Yarn, please write the following command.
npm i yarn-install
Wait for the process to complete. After that, don't forget to activate the yarn-install.js file with the command,
3. Adding the Application Package
Okay, now Yarn has been successfully installed. Then how do you add applications to Yarn? We know Yarn is a package manager. A package manager is a package of installing, updating, configuring and removing software / application packages. So, of course you can easily add packages / modules to your hosting via Yarn. Write the following command,
yarn add package name
You can search for a list of applications at https://yarnpkg.com/en/packages .
For example, this tutorial will install express.js using Yarn. As for how,
yarn add express
To activate express.js, please write,
./node_modules/yarn-install/bin/yarn-install.js add express
4. Deleting the Application Package
To delete a package, please write the following command,
./node_modules/yarn-install/bin/yarn-install.js remove the package name
For example: ./node_modules/yarn-install/bin/yarn-install.js remove express
Comparison of Yarn Speed â€‹â€‹and NPM
To compare Yarn and NPM speeds you can experiment by writing the following command,
The following command is used to find out the time it takes for NPM to install the express.js package
After that, try experimenting to find out how long it will take Yarn to install express.js.
time ./node_modules/yarn-install/bin/yarn-install.js add express
From the results of these experiments, it can be concluded that Yarn has more speed than NPM.
There are several package managers that you can choose from, including NPM or Yarn. Each of these package managers has its own strengths and weaknesses. In terms of speed, Yarn is indeed superior when compared to npm which has a version below 5.0. How to install Yarn on Hosting is also easier because you can do several installations at one time. Do you want to have cheap hosting with the best quality? Try following the Tips for Choosing a Hosting for Beginners so that you know better how hosting is right for you!