Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Guide to setting up a local NPM registry


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@

Then edit the local.ini config to add:

registry.npm:5984 = /registry/_design/app/_rewrite

secure_rewrites = false

Restart CouchDB after editing its config, and make sure to add registry.npm to your hosts file (or similar).

Clone then cd into the directory. Run npm install semver couchapp.


We want a custom NPM config file to prevent interference with regular Call it ~/.localnpmrc and add the following:

registry = http://registry.npm:5984/ = http://admin:password@

Then alias NPM so it uses your new config:

alias localnpm='npm --userconfig=/full/path/to/.localnpmrc'

Actual setup

In the checkout:

localnpm run start
localnpm run load

If this is an initial setup:

curl -k -u admin:password -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.

Using NPM

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.


This comment has been minimized.

Copy link

@ab077u ab077u commented Mar 4, 2020 could be an off-the-shelf alternative. Since the above seems to be bit outdated.


This comment has been minimized.

Copy link
Owner Author

@novemberborn novemberborn commented Mar 4, 2020

Yea, it's 7 years old!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment