by Siddharth Kshetrapal
npm cache: the unsung hero
But there’s an npm feature that does not get nearly the attention it deserves.
Like Yarn, npm also has a built-in caching mechanism that can make subsequent installs super fast.
Here are some benchmarks:
That’s crazy, right? And guess what: this feature has been available to you this whole time, but it’s disabled by default.
How to enable npm cache
npm config set cache-min 9999999
Now install your packages as usual:
npm install express
You can try out these benchmarks for yourself using this repository:
Note that Yarn is not just about speed — it has other features like consistent installs, which set it apart.
But, if speed is an important consideration for you — as it sure is for me — you should give npm another try, this time with cache.
P.S. You should totally follow me on twitter.