npmjs.orgThe design doc for The npm Registry CouchApp
InstallingYou need CouchDB version 1.4.0 or higher. 1.5.0 or higher is best.
Once you have CouchDB installed, create a new database:
You'll need the following entries added in your
curl -X PUT http://localhost:5984/registry
[couch_httpd_auth] public_fields = appdotnet, avatar, avatarMedium, avatarLarge, date, email, fields, freenode, fullname, github, homepage, name, roles, twitter, type, _id, _rev users_db_public = true [httpd] secure_rewrites = false [couchdb] delayed_commits = false
Clone the repository if you haven't already, and cd into it:
Now install the stuff:
git clone git://github.com/npm/npmjs.org cd npmjs.org
Sync the ddoc to
Next, make sure that views are loaded:
npm start \ --npmjs.org:couch=http://admin:password@localhost:5984/registry
And finally, copy the ddoc from
npm run load \ --npmjs.org:couch=http://admin:password@localhost:5984/registry
Of course, you can avoid the command-line flag by setting it in your ~/.npmrc file:
npm run copy \ --npmjs.org:couch=http://admin:password@localhost:5984/registry
_prevents any other packages from seeing the setting (with a password) in their environment when npm runs scripts for those other packages.
Replicating the RegistryTo replicate the registry without attachments, you can point your CouchDB replicator at . Note that attachments for public packages will still be loaded from the public location, but anything you publish into your private registry will stay private.
To replicate the registry with attachments, you can point your CouchDB replicator at .
Using the registry with the npm clientWith the setup so far, you can point the npm client at the registry by putting this in your ~/.npmrc file:
You can also set the npm registry config property like:
registry = http://localhost:5984/registry/_design/app/_rewrite
Or you can simple override the registry config on each call:
npm config set \ registry=http://localhost:5984/registry/_design/app/_rewrite
npm \ --registry=http://localhost:5984/registry/_design/app/_rewrite \ install <package>
Optional: top-of-host urlsTo be snazzier, add a vhost config:
[vhosts] registry.mydomain.com:5984 = /registry/_design/app/_rewrite
registry.mydomain.comis the hostname where you're running the thing, and
5984is the port that CouchDB is running on. If you're running on port 80, then omit the port altogether.
Then for example you can reference the repository like so:
npm config set registry http://registry.mydomain.com:5984