Managing development of 2+ nodejs packages with dependencies

I am developing 2 node.js packages, each managed in their own git repository. Package B depends on package A, so my local directory structure looks like this:


If I make a change to the local code of A1, I would like to test it with B before pushing it to the public repository. How can I do this?

In it's current state, B has it's own local copy (A2), so it is referencing a different version. B is a public package, so I would like to avoid directly modifying the source code of B to reference A1.

One possible solution is to have 2 local copies of B: B1 is the released, public version that has it's own local dependency on A2, and B2 is my own private version that directly references A1 using something like require('./../A1').


This seems kind of ugly (and would force me to maintain 2 copies of B), and I'm wondering if there's a recommended way to handle this situation?



In simplest case symlinks will do the trick. But you may go further and use some kind of fancy build system like grunt, gulp and so forth. I'm using classic make scripts for all of my projects. So you can just copy one project into another before testing it e.g:

NPM = /usr/bin/env npm
MODULES = ./node_modules/
DEPENDENCY = project_a/

default: test

test: copy
    $(NPM) test

    @rm -rf $(MODULES)$(DEPENDENCY)

    @rm -rf $(MODULES)
    $(NPM) install

.PHONY: test

It is not the best build script but it will do the job. Most unix systems will have make installed. So it is pretty portable too.

Need Your Help

JavaScript array iteration method


I have a for loop which iterates through all items:

getAttribute cannot return class in IE7?

javascript internet-explorer-7

I need to find random nodes according to random attribute values.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.