April 30, 2020
3 least Read
For developers, the use of dependency managers is very common. Thanks to this, they avoid having to install dependency manually and avoid wasting time. That's why in this tutorial, we will show you how to install Yarn on Ubuntu to improve project development on. VPS!
What is yarn?
Yarn's speed is due to efficient use of cache to eliminate the need to download libraries many times. Meanwhile, checksum verifies the integrity of libraries to ensure that Yarn is very secure, so reliable.
Now, we will introduce how to install Yarn on Ubuntu 18.04.
How to install Yarn on Ubuntu 18.04
The most effective way to install Yarn on Ubuntu 18.04 is through its repository. We will be able to update the app along with the rest of the system easily. The steps to install Yarn are as follows:
1. Access the server via SSH
To do this, we must access the server running Ubuntu 18.04. If you get in trouble, see PuTTY instructions ours.
2. Add GPG key
Run the following command:
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
With the above command, we have added the necessary GPG key to ensure the downloaded packages are authentic.
3. Add Yarn's Repository
After that, we can add Yarn's repository with the following command:
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
4. Update the system and Install Yarn on Ubuntu
Now, all we need to do is refresh the source of the software and install Yarn on Ubuntu using APT.
sudo apt update sudo apt install yarn nodejs
5. Check the version of Yarn
Then, to check if the installation was successful, we can export the installed version:
yarn init v1.15.2
And as we can see, Yarn's installation was successful and we're ready to go.
How to use Yarn on Ubuntu
Basic usage of Yarn is quite simple. First of all, we start the new project with the following command:
yarn init project_name
After that, we will be asked a few project-related questions that will later create the file .json, where the dependency will be placed. If we want Yarn to use the default information for the file, we press enter for each question.
To add dependency to the project, simply use the following command:
yarn add [package]
However, it is also possible to define a specific version of the package or library as the project's dependency.
yarn add [package]@[version]
To update the package, we use the upgrade directive and the package name. For example:
yarn upgrade [package]
We can also specify the version of the package to be updated:
yarn upgrade [package]@[version]
Alternatively, we can remove the package from the project with the command:
yarn upgrade [package]
Finally, to install all of the identified dependencies, issue the following command:
Remember that the dependency is defined in the file packages.json.
On the other hand, you should visit Yarn's website and consult official document. This way, you get more information and can make the most of the potential of this popular tool. Install yarn now!
- Manual Putty to VPS server administrator or
- Hướng Dẫn Kiếm Tiền Với incrasebux.com
- Why should you choose WordPress theme framework for your website?
- 6 cloud storage service worth using today
- Bitcoin price unexpectedly plummeted to $ 8,100, over $ 185 million of Long orders were liquidated on BitMEX