TL;DR
As the saying goes: You don’t know the extent of the pain you have suffered until you have found some relief. Okay, well, that may not be a saying at all, but it will be the feeling you have when you make the switch from npm to Yarn.
The Problem
npm is slow, non-deterministic AND has been the best way to manage your node.js package installations until now.
How Yarn Came to Be
Facebook decided that the bandaids and workarounds they employed to make npm scale to their needs had gone far enough. They decided to build their own tool that cleaned up the package install workflow. You can read more about it on Facebook’s Yarn site, but I’ll save you the time: Use Yarn!
Reasons to Switch
- Yarn uses the same package.json configs you have setup in your repo
- Once Yarn is installed (with some irony — using npm), replace your “npm install” with “yarn” and you’re done
- The install time is 15x faster. I tested Yarn out on a simple React environment I’ve been using. Using npm, the installation took about 5 minutes (usually ran during a bathroom break). Yarn took about 20 seconds. Nuff said.
Making the Switch
In your project’s root directory, where package.json is located (or where you usually run “npm install”):
#> npm install -g yarn
#> yarn
So, wow, right?! Why the hell have I been wasting time with npm? No longer.
The real question is – why are you?
Update: Yarn is having an upgrade issue. To resolve follow instructions here: https://github.com/yarnpkg/yarn/issues/1139#issuecomment-285935082