Gadi Gadi - 1 year ago 97
Git Question

Node.JS: Working with multiple Git repositories

We have a node.js project with a few modules which spans across multiple Git repositories. The modules have dependencies between them.

For example:

module resides in its own repository.
module resides in a separate repository, and has a (npm) dependency on

So, the directory structure in
includes (once
npm install
is executed)

Our problem is, when developers are working on
, they some times need to modify
as well. In order to 'see' their changes, they have one of two options we currently use: Either modify
(which is ugly, untracked, etc.), or modify the
repository, then push+npm install their changes (which, while cleaner, is quite cumbersome).

What we're wondering is if there's a better alternative for this work process...

Answer Source

I assume you are using them as a dependency using package.json, which allows you to require them with the name and not the path. (You also have goodies of the version handling with this.) . I couldnt find any option to remove the step of npm install but I did found something which can remove the step of git push and will make your npm install faster.

Local dependencies.
Using local paths as dependencies which can be your some other git repo, you can make changes directly to the git repo of your dependency. This allows you to change the code and test it without pushing. (Although you have to do npm install again in the main module, which will duplicate the working copy of your dependency in your node modules).

Word of caution : You have to take care that you push the final changes made to your dependency code once you have finished working on both, otherwise other developers might go in inconsistent state.

How to add local dependencies

 "dependencies" : {
       "here" : "file:./test/git/repo/here#0.0.1"

Note that this local dependency feature was added to npm in version 2.0. So you might need to update your node if you dont already have npm 2.0+