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 yarn
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 | bash
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 --version
Initializing a Yarn Project
Run the below command to initialize a new project.
yarn init
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.
yarn
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 lodash
As a result, the below output appears.
Next, you can use the –dev flag to add a package as a dev dependency.
yarn add babel-cli -D
Update a dependency
Here is the command to update a dependency.
yarn upgrade lodash
Or you can run the below command to update all the dependencies.
yarn upgrade
Remove a dependency
You can run the below command to remove a dependency.
yarn remove lodash
Add a global dependency
If you wish to add a global dependency then run the below command.
yarn global add lodash
[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.
0 Comments