Install CouchDB. This guide assumes 1.3.1. Set up an admin account.
Create the database required by NPM:
curl -X PUT http://admin:password@127.0.0.1:5984/registry
Then edit the local.ini
config to add:
[vhosts]
registry.npm:5984 = /registry/_design/app/_rewrite
[httpd]
secure_rewrites = false
Restart CouchDB after editing its config, and make sure to add registry.npm
to your hosts file (or similar).
Clone https://github.com/isaacs/npmjs.org then cd
into the directory. Run npm install semver couchapp
.
We want a custom NPM config file to prevent interference with regular https://npmjs.org. Call it ~/.localnpmrc
and add the following:
registry = http://registry.npm:5984/
npmjs.org:couch = http://admin:password@127.0.0.1:5984/registry
Then alias NPM so it uses your new config:
alias localnpm='npm --userconfig=/full/path/to/.localnpmrc'
In the npmjs.org
checkout:
localnpm run start
localnpm run load
If this is an initial setup:
curl -k -u admin:password http://127.0.0.1:5984/registry/_design/scratch -X COPY -H destination:_design/app
Or if you're updating a previous registry:
localnpm run copy
Create the following document in the registry
database:
{
"_id": "error: forbidden",
"forbidden": "must supply latest _rev to update existing package"
}
Without this document you can't publish newer versions of existing packages.
Use adduser
to create your user account.
When publishing a package, make sure the following is in its package.json
:
"publishConfig": {
"registry": "http://registry.npm:5984"
}
To add other users as maintainers of your package your user account must be able to view the _users
document of those other users. E.g. in the security settings for the _users
database add your username under Admin Names.
https://verdaccio.org/ could be an off-the-shelf alternative. Since the above seems to be bit outdated.