How do people manage JavaScripts projects that contain multiple NPM packages?

With my Index Data colleagues, I am working on “Stripes”, a UI toolkit for the in-progress library services platform FOLIO. Because it runs in the browser, the Stripes code pretty much has to be JavaScript, and because it’s a non-trivial bit of work, it brings in multiple modules from elsewhere — something that is traditionally done using NPM, the Node Package Manager, which is what we too are using.


But Stripes is made up of several NPM packages: stripes-core, stripes-connect, and so on. And they use each other. In particular (let’s make things simple by picking a single example), stripes-core uses stripes-connect.

How can we run a development version of Stripes using only local git checkouts? It seems to me that this should be a very common pattern of usage, and there should be a well-known way of doing it — but if there is, we’ve not been able to find it.

What we’re doing makes us quite sad. We check out the two git modules stripes-core and stripes-connect next to each other in the same directory. Then we trick NPM so that when building stripes-core and pulling stripes-connect in from the @folio namespace, it gets it from the adjacent checkout:

$ cd stripes-core
$ mkdir -p node_modules/@folio
$ cd node_modules/@folio
$ ln -s ../../../stripes-connect
$ cd ../../
$ npm install

This works, but there are two problems:

  1. It’s horrible.
  2. It doesn’t work at all with Yarn, the NPM replacement that all the cool kids are using. (I don’t know why, I’ve not looked into it beyond just trying to run Yarn and seeing what happens.)

It’s left me feeling we must be missing something. This kind of hackery can’t be the best solution, can it? Surely we’re not the only people developing JS programs that consist of multiple modules? There has to be a standard way of doing this, right?

Does anyone know what it is? (Ideally a way that works with both NPM and Yarn.)

4 responses to “How do people manage JavaScripts projects that contain multiple NPM packages?

  1. `npm link` is a shortcut for doing this:

    Yarn has something similar.

  2. npm link?

  3. Thank you both, I will look into it.

  4. There’s also lerna, which is what babel uses for a monorepo approach:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.