npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

There needs to be a way to denote OS-specific dependencies

Currently, the only real way you can have OS-specific dependencies is to list it in optionalDependencies and on that particular OS, run npm install dep@semver. For a concrete example of the issues this causes, Chokidar, although it doesn’t mandate it, heavily implies the need for .

Could there be something like a platformDependencies field, with keys being valid process.platform values and values being the list of dependencies? Also, a supportedPlatforms field would be nice to warn users installing it for all platforms when your module only works on certain platforms. (This warning would only be suppressed if either your supportedPlatforms is a subset or equal to theirs or it’s located in a matching platformDependencies field. It’d be generated across all platforms so it’s less likely to get missed.) And to save it to a platform in your package.json, you could use --save-platform platform/--save-platform-dev platform.


Concerning supportedPlatforms, I believe os already does that.


Yeah, I noticed that after I posted this…

I’m working on an RFC for something a bit more flexible.