Do you need more information about "Yarn Package Manager"? This article will tell you more about it.
Yarn is a package manager which replaced what npm client or other package managers represented. It is compatible with the npm registry.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our customers to perform Software installation tasks on their Server and Systems.
Now, let us take a look on how to install yarn package manager.
More about Yarn package manager?
It is built to to much more safer, more secure and more reliable than npm.
Steps to follow to install Yarn Package Manager.
There are different methods of getting Yarn Package Manager installed. One of such is via npm which we are going to consider in this guide.
To install yarn, simply log into your Server as a root user and run the command below;
npm install -g yarn
Next, install npm via a bash script command as shown below;
curl -o- -L https://yarnpkg.com/install.sh | bash
Testing Yarn after Installation
After installation of Tarn, it is important to test it to see that it is working correctly.
Start by checking the version of yarn installed by running the command below;
How to Start a Yarn Project?
To initialize a new Yarn project, run the command below;
How to install the dependencies which Yarn requires to function?
There are dependencies which are retrieved from your new project’s "package.json" file stored in the yarn.lock file.
To install the dependencies for a new Yarn project, run the command below;
How to manage Yarn Dependencies?
In this instance, we will work with lodash.
Start by adding the project dependency by running the command below;
yarn add lodash
Next, use the flag "–dev" to add a package as a dev dependency as shown below;
yarn add babel-cli -D
How to update a dependency?
To update a dependency, run the command below;
yarn upgrade lodash
Alternatively, to update all the dependencies, run the command below;
How to remove a dependency?
To remove a dependency, run the command below;
yarn remove lodash
Adding a global dependency?
To add a global dependency which will be available for every directory on the Server, run the command below;
yarn global add lodash