djechlin
djechlin

Reputation: 60768

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

npm is very good at supporting packages publishes to the global/central npm repo, which doesn't work well for private, application code. npm 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 npm packages tend to be very tight and small, whereas my git repos tend to be larger, and will include several npm packages. I do not know any way to attain this granularity while pointing to a github URL. How to solve this?

UPDATE

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

Upvotes: 15

Views: 10254

Answers (2)

laktak
laktak

Reputation: 60003

You could also set up your own local npm repository.

Upvotes: 1

Jacob
Jacob

Reputation: 441

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!

Upvotes: 14

Related Questions