npm-interlink v0.2.0
npm-interlink
Sets up several node projects for local development using npm link.
Especially useful in the context of nvm and / or having many projects that depend on each other.
Why
- quickly setup a bunch of modules for local development or experimentation (install or link)
- link a bunch of modules among themselves, without having to remember the interdependencies
- relink the same modules in another context, e.g. because
nvmlinks modules per node version - easily link the modules incrementally, just rerun it and new modules get linked, linked to
How
All it needs are project paths, or it tries the immediate subdirectories of the current dir.
Any dir with package.json will be npm linked - making its module global.
Any dir with package.json dependencies referencing a linked module will get them linked to its node_modules.
Already linked modules that are not explicitly part of an interlink set will not be linked to.
Use
Clone some node.js projects and run npm-interlink in their parent directory.
Clone is really a metaphor here, as npm-interlink is agnostic to version control.
Options
Because npm-interlink makes it easy to setup many node projects, potentially saving a lot of time that would be otherwise spent waiting to oversee command results, I added some options that can ask it to do something other than its default behavior.
-ior--installwill install thenode_modulesfor each package and skip linking altogether - keep in mind thatnpm linkand thusnpm-interlinkwithout options will also install, so this is for install only-oor--onlywill only interlink modules that are already linked, this is perhaps because one wants partially interlinked modules, alsonpm link moduleis a very fast command compared tonpm installornpm link(self), thus linking incrementally is a good pattern, perhaps this should be the default...
Configure
Create a .npm-interlink file containing the list of dirs / modules to interlink.
Use relative or absolute paths - one per line.
For example, here is how I interlink the gulpsome beverage modules, plus a couple of other projects of mine that they depend on:
be-goods
beverage
../childish-process
gulp-cause
gulp-harp
gulp-npm-run
gulp-npm-test
hal-rc
../sourcegateHow you setup the directory structure is entirely up to you, though this obviously works well for organizations (collections of repos). One can start with a subset and add more projects as the need to work on them arises.
