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
I had this same problem, and after some searching around, I found Reggie (https://github.com/mbrevoort/node-reggie). It looks pretty solid. It allows for lightweight publishing of NPM modules to private servers. Not perfect (no authentication upon installation), and it's still really young, but I tested it locally, and it seems to do what it says it should do.
That is... (and this just from their docs)
then cd into your module directory and...
finally, you can install packages from reggie just by using that url either in a direct npm install command, or from within a package.json... like so
or..
Structure your code in an accessible fashion like below. If this is possible for you.
Within MainApp @ NodProjs\Apps\MainApp\
You may need to update package.json as:
This worked for my situation.
Starting with arcseldon's answer, I found that the team name was needed in the URL like so:
And note that the API key is only available for the team, not individual users.
In your private npm modules add
to your package.json
Then to reference the private module in another module, use this in your package.json
Update January 2016
In addition to other answers, there is sometimes the scenario where you wish to have private modules available in a team context.
Both Github and Bitbucket support the concept of generating a team API Key. This API key can be used as the password to perform API requests as this team.
In your private npm modules add
to your package.json
Then to reference the private module in another module, use this in your package.json
where team name = myteamname, and API Key = aQqtcplwFzlumj0mIDdRGCbsAq5d6Xg4
Here I reference a bitbucket repo, but it is almost identical using github too.
Finally, as an alternative, if you really don't mind paying $7 per month (as of writing) then you can now have private NPM modules out of the box.
or
somedir
must contain thepackage.json
inside it.It knows about git too: