October 17, 2016
npm install -g yarn
(otherwise see here)
After that, yust use Yarn as a drop-in-replacement for NPM.
I wanted to know, if it’s really that faster and did some measuring of my current project with a lot dependencies (I always deleted the
node_modules folder before running the commands):
$ npm install > 1:53 mins $ yarn > 1.39 mins
Ok, that was not that much faster. But, and this is the trick: Yarn becomes much more faster, if you run it after the first time when it has to fill it’s offline cache.
Wait, what? Offline? Yes, Yarn caches all packages it downloaded once, no matter for which project. So, if you have a dependency in project A and B, you just have to download it one time. It’s not being downloaded every time you do a install process. This is not onyl much more faster, because Yarn doesn’t have to check the central repository, you can use it also when you don’t have any internet connection during travel or so.
So, the second run (again with deleted
node_modules folder) with Yarn resultet in:
$ yarn > 18 secs
That’s pretty impressive! Wow! Fast!
npm install: 1:53m— Niko Köbler (@dasniko) 14. Oktober 2016
yarn: 1:39 (1st time)
yarn: 18s (2nd time)
Oh, yes, of course you can use the same NPM repository as before, Yarn is able to use it!
If you want to know more about Yarn, visit the official website, and/or have a look at this awesome cheatsheet!
« JavaOne 2016 Keynote Comments Single-Sign-On with Keycloak at W-Jax 2016 »