I wrote a short protip this morning about the European mirror for npm. Developers in Europe (such as myself, based in Manchester, UK), will find this Germany based mirror significantly faster and possibly more reliable.
You can force the use of the European mirror by simply appending the
--registry http://registry.npmjs.eu flag to the end of your command, however, I recommend you just set up an alias, e.g:
How much faster?
Rather than just claim it is faster, I want to take this blog post further and prove that it’s faster.
Let’s pick a package with a few dependencies,
First, let’s run
npm cache clean to remove any data in the npm cache folder. Without supplying a path, this clears the entire cache. A quick run of
npm cache ls confirms this.
How do we actually go about timing an
npm install? Well, there’s a basic command called
time that’s built into most shells and allows us to easily see the execution time of a command (both “real time” used and system time). This is accurate enough for what we need.
Let’s give it a go:
Now let’s clear the cache again and try the European mirror:
21.573s vs 11.799s means it’s almost twice as fast for me to use the European mirror of the npm registry.
Damn, now I don’t have long enough to make a coffee.