This may be a good way to do this, depending on your setup.
npm package.json supports the os key as well as optionalDependencies
os can be used to indicate which OS the module can be installed on. optionalDependencies are module dependencies that, if they cannot be installed, npm skips them and continues the installation.
Thus, your module may have an optional dependency for each OS, and only the one that works / will be downloaded / installed. ^
EDIT: As @Sebastien mentions below, this approach is dangerous . For any given OS, at least one of your dependencies is “required” and the rest is “optional”. Providing all versions of the dependencies does not necessarily mean that if your installation fails for a good reason, it will silently skip the installation and you will not need the dependency that you really need.
TinyTimZamboni Sep 26 '14 at 23:14 2014-09-26 23:14
source share