#525·zx

Improve `--install`

Author: zloirockCreated Oct 8, 2022Updated Sep 25, 2026
Labelsfeatureresearch

--install option is an interesting feature. When you maintain a big project, it could significantly help you - for example, avoid loading to CI unnecessary heavy dependencies that are used only in some scripts. However, now this option has some significant issues.

  • At this moment, this option install all dependencies of the script - even if this dependency is already installed at the root of the project.
  • It's problematic to control versions of dependencies if they are defined as comments of imports - this dependency can be used in some different scripts, the actual tools for updates checking can't get access to versions from those comments.
  • Dependencies from the monorepo (workspaces) also installed and resolved incorrectly.
  • It's problematic to configure installing process.

  • The first issue can be solved by checking the existence of the dependency in the top-level node_modules of the project before installing.
  • The second can be solved by adding a way to define those versions in a package.json (top-level of the project or defined in another place) without installing those dependencies. In the case of the top-level package.json, it can be optionalDependencies.