The main idea is to make an official NPM mirror as detailed here: https://github.com/npm/npm-registry-couchapp
Unfortunately the above instructions appear to be flawed and didn't working for me. Thankfully someone has taken the time to create an updated set of installation instructions: https://github.com/rvagg/npmjs.org/tree/new-install-docs
Only one problem remains with the above instructions and that is the credentials for the copy script. In copy.sh you need to fix the credentials for curl. Change this (line 46):
-curl -k ${auth:+-u "$auth"} "$url/_design/scratch" \
to this:
curl -k -u admin "$url/_design/scratch" \
Where 'admin' is the name of the administrator account you chose for your Apache CouchDB. You will be then be prompted for the password.
I used version 1.5.0 for my installation. I immediately fixed admin party mode and used the credentials during the installation.
To setup replication that will persist beyond reboots I created a document in the _replicator database using the following curl script:
curl -H 'Content-Type: application/json' \
-X POST http://admin:[email protected]:5984/_replicator \
-d '{"id": "npmjs", "source": "https://skimdb.npmjs.com/registry", "target": "http://admin:[email protected]:5984/registry","continuous":true}'
Don't forget to replace your username/password in the above curl script. I chose to use the light replication (skimdb) and I am only syncing module data and not the attachments. Change the source url as desired.
As detailed in both the offical and updated instructions above you can now set your registry value in ~/.npmrc to:
registry = http://yourserver:5984/registry/_design/app/_rewrite
If you're working with multiple repositories I recommend installing nmprc to easily switch between profiles:
npm install -g npmrc