Posted on 8/9/11 by Felix Geisendörfer
Thanks to Isaac, npm is getting more and more awesome by the hour. One of the coolest recent additions (you need at least v1.0.26) is the ability to specify private git repositories urls as a dependency in your package.json files.
At transloadit, we are currently using the feature to move some of our infrastructure code into separate packages, allowing for those to be tested and developed in isolation making our core application easier to maintain and work on.
The syntax for referencing a git repository (and commit) is as follows:
This will include a private npm module called
"private-repo" from GitHub. The
url also contains an optional refspec (
#v0.0.1) that tells npm which branch,
commit, or in this case tag you want to have checked out.
Now of course this is not the only way to do private npm repositories, but it is much simpler than running your own registry, so I would recommend it to most people.
Before you head of to play with this, here is a final tip that may safe you
some headaches. In all your private npm modules, add
"private": true to your
package.json. This will make sure npm will never let you accidentally publish
your secret sauce to the official npm registry.
Happy hacking, --fg
PS: When deploying, don't forget that you need to authorize the servers ssh key for the GitHub repository you are depending on.
You can skip to the end and add a comment.
This post is too old. We do not allow comments here anymore in order to fight spam. If you have real feedback or questions for the post, please contact us.