Bobcares

Yarn Package Manager – A Quick Introduction

by | Oct 30, 2020

Eager to know about ‘Yarn Package Manager’? Take a peek at this blog.

Here at Bobcares, we have seen several such Software installations queries as part of our Server Management Services for web hosts and online service providers.

Today we’ll see how to install yarn package manager.

 

What is a Yarn package manager?

Yarn is an open-source JavaScript package manager that is developed by Facebook.

Also, it replaces the npm client or other package managers while it remains compatible with the npm registry.

Moreover, the features are the same as existing workflows while operating faster, more securely, and more reliably.

 

How to install Yarn Package Manager

There are different ways to install the Yarn. Here we are installing it via npm.

npm install -g yarnCopy Code

In case, if you don’t have the npm then you can install it via a bash script.

curl -o- -L https://yarnpkg.com/install.sh | bashCopy Code

 

Testing the Yarn Installation

You can run the below command to check if the Yarn installation is done properly or not. Also, you can see if any latest version is available.

yarn --versionCopy Code

 

Initializing a Yarn Project

Run the below command to initialize a new project.

yarn initCopy Code

 

Installing Yarn Dependencies

Run the below command to install all the dependencies for a project. The dependencies are retrieved from your project’s package.json file. Then they are stored in the yarn.lock file.

yarnCopy Code

 

Managing Yarn Dependencies

Here we are considering lodash for our examples.

 

Add a project dependency

Run the below command to add a dependency.

yarn add lodashCopy Code

As a result, the below output appears.

yarn package manager

Next, you can use the –dev flag to add a package as a dev dependency.

yarn add babel-cli -DCopy Code

 

Update a dependency

Here is the command to update a dependency.

yarn upgrade lodashCopy Code

Or you can run the below command to update all the dependencies.

yarn upgradeCopy Code

 

Remove a dependency

You can run the below command to remove a dependency.

yarn remove lodashCopy Code

 

Add a global dependency

If you wish to add a global dependency then run the below command.

yarn global add lodashCopy Code

[Need any further assistance with Yarn related queries? – We’re available 24*7]

 

Conclusion

In short, you can install Yarn using different ways. Today, we saw how our Support Engineers install Yarn using npm.

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Speed issues driving customers away?
We’ve got your back!