I want to do something like this, so npm install also installs the package.json of ../somelocallib or more importantly its dependencies.
"dependencies": {
"express": "*",
"../somelocallib": "*"
}
Put somelocallib as dependency in your package.json as normal:
"dependencies": {
"somelocallib": "0.0.x"
}
Then run npm link ../somelocallib and npm will install the version you're woking.
app@0.0.1 /private/tmp/app
└── somelocallib@0.0.1 -> /private/tmp/somelocallib
Reference: link(1)
Edit: this feature was implemented in the version 2.0.0 of npm. Example:
{
"name": "baz",
"dependencies": {
"bar": "file:../foo/bar"
}
}
Any of the following paths are also valid:
../foo/bar
~/foo/bar
./foo/bar
/foo/bar
This works for me: Place the following in your package.json
"scripts": {
"preinstall": "npm install ../my-own-module/"
}
While i was searching for the exact same thing, it happens that just a few days ago this feature was finally, after 3 years (!!) implemented. It is now possible to specify local node_module installation paths in your package.json directly, see npm doc here !
If you want to further automate this, because you are checking your module into version control, and don't want to rely upon devs remembering to npm link, you can add this to your package.json "scripts" section:
"scripts": {
"postinstall": "npm link ../somelocallib",
"postupdate": "npm link ../somelocallib"
}
This feels beyond hacky, but it seems to "work". Got the tip from this npm issue: https://github.com/isaacs/npm/issues/1558#issuecomment-12444454
Actually, as of npm 2.0, there is support now local paths (see here).
This should now be possible (as of npm v2.0). They added support for local modules (whos dependencies would also be installed). I create an example for you: http://www.devworkflows.com/posts/using-local-npm-modules-in-npm-v2-0/
This worked for me: first, make sure the npm directories have the right user
sudo chown -R myuser ~/.npm
sudo chown -R myuser /usr/local/lib/node_modules
Then your in your package.json link the directory
"scripts": {
"preinstall": "npm ln mylib ../../path/to/mylib"
},
"dependencies": {
"mylib" : "*"
}
I know that npm install ../somelocallib works.
However, I don't know whether or not the syntax you show in the question will work from package.json...
Unfortunately, doc seems to only mention URL as a dependency.
Try file:///.../...tar.gz, pointing to a zipped local lib... and tell us if it works.