If an NPM package is designed both as a global command and as a dependency for other applications / packages, may I specify its dependencies for different installation cases?
E.g., package mypkg depends on package foo when it runs as a global command. However, foo is unnecessary when mypkg is installed and used as a dependency for other applications / packages. How to prevent foo installed when
--global option is absent?
[zh-CN] 例如，mypkg 作为全局命令运行时，需要依赖 foo；但如果它仅作为其他应用程序或包的依赖项，则并不依赖 foo。怎样可以在非全局安装模式下，阻止安装 foo？
In another word, I mean
# Please DO NOT install **foo**. npm install mypkg # Please DO install **foo**. npm install --global mypkg