Spoiler: You must go for Yarn! :)

Well, Facebook launched Yarn package manager for JavaScript. The team also got help from companies like Google,Tilde and Exponent. Yarn is available on GitHub because other companies contributed to the project, the team decided to host it outside of Facebook’s own repository. Let me assume you’re a JavaScript enthusiast so, for sure you’ve worked with node modules and you’re familiar with node package manager which is NPM in short. In case you have never heard about NPM, start your new life with Yarn ; It’s faster than you can even imagine.

Let me explain a bit about Node Package Manager(NPM) . We use Package manager to find and use existing code or libraries. Like we could install jQuery, React, Redux, VueJS, Vua-Redux anything from the package manager and it’s super easy. Just by writing.

npm i packageName --save

NPM also allows developers to upload their created libraries or code block.

Why Yarn, when we have NPM?

This is the burning question now. NPM works great for thousands of developers but it won’t work that great for companies like Facebook , Google. If you’ve deleted your node_modules folder for any reason and run ‘npm install’ in the project console, npm will re download each and every package along with their dependencies which is too much time killing. Yarn is great in this purpose. It caches every package it downloads. If you have ever downloaded the package before, you can install it in offline mode too.It also parallelizes operations to maximize resource utilization so install time are faster than ever, like the rocket trying to escape the earth’s gravity!

Yarn is super secured. It uses checksums to verify the integrity of every installed package before its code is executed.

Yarn is reliable . According to their voice, “ Yarn is able to guarantee that an install that worked on one system will work exactly the same way on any other system.”

Deep diving into Yarn:

If you had npm installed before and willing to check Yarn’s power, just simply run the command below.

npm install --global yarn

If you din’t have npm installed before, check there website documentation for more details. https://yarnpkg.com/en/docs/install

How to Yarn?

For the most of it, if you know NPM, you’re already set!

Let’s start with the most popular npm command ‘npm init’ that sure has a yarn option. That adds a ‘package.json’ file in the root of your project

npm init === yarn init

These are all the same:

npm link === yarn link npm outdated === yarn outdated npm publish === yarn publish npm run === yarn run npm cache clean === yarn cache clean npm login === yarn login npm logout === yarn logout npm test === yarn test

‘Install’ is Yarn’s default behavior

npm install === yarn

The React Js library is saved in your package.json file:

npm install react --save === yarn add react

More ever Yarn has some great features that NPM don’t have. You can check the licenses of your dependencies and you can also generate your licence dependencies. Oliver Combe added a great tool ‘yarn why package-name’ , this will identify why this package is installed and which other packages are dependent over it. Let’s check the examples.

yarn licenses yarn licenses generate yarn why react

Yarn’s another great feature is, it automatically shrinkwrap with the yarn lockfile.

The one last thing we need to know, ‘Well Nothing :P’. Now, you know it all.

Hope we’ll have a great time with yarn. Cheers!