How to install a private NPM module without my own registry?

futlib picture futlib · Apr 30, 2012 · Viewed 190.6k times · Source

I've taken some shared code and put it in an NPM module, one I don't want to upload to the central registry. The question is, how do I install it from other projects?

The obvious way is probably to set up my own NPM registry, but according to the documentation, that involves a lot of hassle.

Can I just install an NPM module that sits on the local filesystem, or perhaps even from git?

npm install --from-git git@server:project

Answer

250R picture 250R · May 1, 2012

In your private npm modules add

"private": true 

to your package.json

Then to reference the private module in another module, use this in your package.json

{
    "name": "myapp",
    "dependencies": {
        "private-repo": "git+ssh://[email protected]:myaccount/myprivate.git#v1.0.0",
    }
}