Using npm in Europe


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 flag to the end of your command, however, I recommend you just set up an alias, e.g:

$ alias enpm="npm --registry"

How much faster?

Rather than just claim it is faster, I want to take this blog post further and prove that it’s faster.

Quick test

Let’s pick a package with a few dependencies, grunt.

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:

$ time npm install grunt
# =4.71s user 1.69s system 29% cpu 21.573 total

Now let’s clear the cache again and try the European mirror:

$ time npm install grunt --registry
# =3.75s user 1.48s system 44% cpu 11.799 total

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.