Quick tip: npm lets you install directories, which is occasionally useful for organizing projects. For example, as a temporary step before uploading packages to npm (think lightweight npm link
).
As an example, let’s assume, we are writing a suite of Node.js-based CLI tools:
suite_of_tools/
tool1/
tool2/
helpers/
Each of tool1
, tool2
and helpers
is an npm package with its own package.json
and node_modules/
.
helpers/
npm lets you do:
$ cd tool1/
$ npm install ../helpers
Then npm does the following:
helpers
.../../helpers/
in tool1/node_modules
."dependencies": {
"helpers": "file:../helpers",
···
}
Et voilà! Now tool1
’s “sibling dependency” on helpers
will be (re)created whenever you do an npm install
for tool1
.