Last updated
The mighty Maciej Malecki created a European npm mirror for all the Node.js developers this side of the Atlantic. It is much faster to install packages from and takes some load off the main registry.
Here are some stats™ on installing the yeoman-generator module.
npm install --registry http://registry.npmjs.org yeoman-generator 10.09s user 1.62s system 47% cpu 24.473 total
npm install --registry http://registry.npmjs.eu yeoman-generator 6.10s user 1.11s system 34% cpu 20.903 total
So 6.10 seconds in Europe, 10.09 seconds from the main registry. Four seconds faster.
You can start using the European mirror right away by running a single command.
npm config set registry http://registry.npmjs.eu
This will update your .npmrc
to include the following line
registry = http://registry.npmjs.eu/
Now when you run npm install
if you haven’t disabled verbose logging you’ll see the http calls going out to the European mirror.
npm http GET http://registry.npmjs.eu/argparse
npm http GET http://registry.npmjs.eu/glob
..
You cannot publish to the European mirror - it is read only. This means there is a little bit of work to do when you want to publish a module. There are a couple of ways to achieve this. You can simply specify the registry when you publish
npm publish --registry http://registry.nodejs.org
Or you can set this in your package.json
file
"publishConfig": {
"registry":"http://registry.npmjs.org/"
}
If you frequently want to switch modules the nrm module may help.
$ nrm ls
* npm ---- https://registry.npmjs.org/
cnpm --- http://r.cnpmjs.org/
eu ----- http://registry.npmjs.eu/
au ----- http://registry.npmjs.org.au/
sl ----- http://npm.strongloop.com/
nj ----- https://registry.nodejitsu.com/
$ nrm use cnpm //switch registry to cnpm
Thanks to hemanth.hm for this tip.
If you are in Europe enjoy a faster, sexier npm experience by switching to the European registry! You can also bask in the warm glow of being a good npm citizen by taking some load off the main repository.
Given CouchDB’s excellent replication capabilities it would be nice to see more mirrors popping up. You could even write a proxy in front of the mirrors to make sure you always have a service available.
Have an update or suggestion for this article? You can edit it here and send me a pull request.
Using HashiCorp Vault with LDAP
How to use HashiCorp Vault to setup an LDAP backed secret store with read-only access for users in groups and read-write access for specific users
Linux and Unix xargs command tutorial with examples
Tutorial on using xargs, a UNIX and Linux command for building and executing command lines from standard input. Examples of cutting by character, byte position, cutting based on delimiter and how to modify the output delimiter.
Copy a file in Go
How to copy a file in Go. The ioutil package does not offer a shorthand way of copying a file. Instead the os package should be used.