npm install /path/to/foo
will simply copy the contents from the specified path into your local package's node_modules
folder. However, if you were expecting this method to ensure that npm update
and npm install
would automatically fetch the latest code from that path and update/install the dependencies of the package at that path, then using this approach is incorrect.
In order to achieve these desired outcomes, you should include that local dependency in your package.json
's dependencies
or devDependencies
(a feature supported by npm since version 2.0). Here's an example:
"dependencies": {
"foo": "file:/path/to/foo"
}
By following the above steps, when you run npm update
or npm install
, the local dependency will be treated similarly to any other dependency in your project.