djechlin djechlin - 2 months ago 11x
Node.js Question

How to support multiple private npm packages living in one git repo?

is very good at supporting packages publishes to the global/central
repo, which doesn't work well for private, application code.
also supports adding a git repo as a dependency, which lets you have a private dependency.

The problem is, as I understand to be best practice, my
packages tend to be very tight and small, whereas my git repos tend to be larger, and will include several
packages. I do not know any way to attain this granularity while pointing to a github URL. How to solve this?


I accepted the answer that says "don't do this, stay on the rails." I agree with this recommendation, but YMMV.


I would suggest that one repo with multiple packages is a bad idea to start with for several reasons. You should be viewing a package as its own entity: independently built, tested, and deployed. All that to say, each package should live in its own repo.

That being said, I definitely understand the benefit of being able to do an npm install <package-group> of one "commons" package and have it grab all the packages you need in one shot. I would suggest looking at the grunt-contrib model for accomplishing this. In short, they have a bunch of grunt-contrib- packages (ex. grunt-contrib-coffee) each living in their own repositories. They then create a separate repository that defines the parent "grunt-contrib" package. All this parent package does is specify dependencies on all of the sub-packages. This allows you to do an npm install grunt-contrib-coffee (for example) and get just the grunt-contrib-coffee package; or you can do npm install grunt-contrib and get their entire suite all in one shot.

Hope this helps!