In an effort to save space, I've installed large packages in a common parent directory to all my projects. The scripts in these projects can refer to modules in this parent directory (see this in Node's documentation), yet npm install
-ing in a freshly-cloned project pulls everything, not just the ones that the project needs on top of the ones inherited from the common parent. Are there any options to make npm install
download only what it needs to?
Minimal example: consider the below file structure.
├ projects
│ ├ package.json <- specifies a dependency on `some_module^1.0.0`
│ ├ node_modules
│ │ └ some_module
│ │ └ ...
│ └ some_project
│ └ package.json <- also specifies a dependency on `some_module^1.0.0`
If npm install
is run in projects/some_project
, it will download some_module
unconditionally.
(Note: this is not related to npm dedupe
and the module duplication it solves, because this is solely a directory hierarchy: the parent directory project doesn't depend on any of the subfolders.)