How to install yarn js on ubuntu 18.04
Yarn js Installation on Ubuntu 18.04
Yarn is a JavaScript package manager compatible with npm that helps you automate the process of installing, updating, configuring, and removing npm packages. It was created to solve a set of problems with the npm such as speeding up the packages installation process by parallelizing operations and reducing errors related to network connectivity. The method to install Yarn JS on Ubuntu 18.04 is covered in this tutorial.
Installation
The first step is to enable the Yarn repository. Make use of the following command
root@linuxhelp1:~# curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
OK
Add the Yarn APT repository to your system’s software repository list using the Following Method
root@linuxhelp1:~# echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
deb https://dl.yarnpkg.com/debian/ stable main
Once the repository is added to the system, update the package.
root@linuxhelp1:~# apt-get update
Get:1 https://dl.yarnpkg.com/debian stable InRelease [13.3 kB]
Hit:2 http://in.archive.ubuntu.com/ubuntu bionic InRelease
Hit:3 http://ppa.launchpad.net/ondrej/php/ubuntu bionic InRelease
Hit:4 http://security.ubuntu.com/ubuntu bionic-security InRelease
Get:5 https://dl.yarnpkg.com/debian stable/main all Packages [8,242 B]
Hit:6 http://in.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:7 http://in.archive.ubuntu.com/ubuntu bionic-backports InRelease
Get:8 https://dl.yarnpkg.com/debian stable/main i386 Packages [8,242 B]
Get:9 https://dl.yarnpkg.com/debian stable/main amd64 Packages [8,242 B]
Fetched 38.1 kB in 1s (35.4 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
656 packages can be upgraded. Run 'apt list --upgradable' to see them.
After updating the package, install Yarn by running the following command.
root@linuxhelp1:~# apt-get install yarn
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libc-ares2 libhttp-parser2.7.1 nodejs nodejs-doc
Processing triggers for man-db (2.8.2-1) ...
Setting up libc-ares2:amd64 (1.14.0-1) ...
Setting up nodejs (8.10.0~dfsg-2ubuntu0.4) ...
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode
Processing triggers for libc-bin (2.27-0ubuntu2) ...
To verify that Yarn installed successfully, run the following commands which will print the Yarn version.
root@linuxhelp1:~# yarn -version
1.12.3
To create a new Yarn project use the yarn init command as shown below.
root@linuxhelp1:~# yarn init my_yarn_project
yarn init v1.12.3
question name (root):
question version (1.0.0):
question description:
question entry point (index.js):
question repository url:
question author:
question license (MIT):
question private:
success Saved package.json
Done in 65.47s.
Once completed, the script will create a basic package.json file containing the information you provided. You can later open and edit this file.
If you want to use another package in your project, you need to add it to the project dependencies.
root@linuxhelp1:~# yarn add npm1
yarn add v1.12.3
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ npm1@1.0.0
info All dependencies
└─ npm1@1.0.0
Done in 2.54s.
With this, the method to install Yarn JS on Ubuntu 18 comes to an end.
Comments ( 0 )
No comments available