Use private NPM registry

I just want to share some private NodeJS modules for reuse in my other projects. A simple private registry is a good choice. sinopia is what I used.

The installation is very easy.

1
2
3
$ yarn global add sinopia
$ sinopia &
$ npm set registry http://localhost:4873/

After this, we can add a user to the new registry.

1
$ npm adduser --registry http://localhost:4873/

Now we need to update the module’s package.json to remove the "private": true and add following publish config.

1
2
3
"publishConfig":{
"registry":"http://localhost:4873"
}

Then we can run npm publish to publish the module. The new published module can be installed using npm or yarn in other projects.

Comments