Can you add support to install some dependencies only when a package is installed globally so it has a binary file which can be used as a command program?
This would be useful.
For example, one package can be used as Node.js library and command program. In this case, some of the dependencies are needed for library and some additional dependencies are needed for command program (for example for some styling or handling inputs).
But when a package is used locally as a library, additional command program dependencies are not needed. They can also be very heavy so space will be used without need.
If my idea would be implemented, NPM or Yarn will install that additional command program dependencies only when a package is installed/used as a global package with command program. If a package is installed as a local library, only normal dependencies will be installed.
To implement this, there should be additional dependency section in
package.json, called something like
binDependencies. They should be installed only when a package is installed globally (to use command program) or when a package is installed locally as dev dependency (in case if command program is needed for testing, linting, bundling…). In other cases, when a package is installed locally as a normal dependency, that section should be ignored.