There's a possible good way of doing this, depending on your setup.
npm package.json supports an os key, and also optionalDependencies
os can be used to specify which OS a module can be installed on. optionalDependencies are module dependencies that if they cannot be installed, npm skips them and continues installing.
In this way you can have your module have an optional dependency for each OS, and only the one which works will be loaded/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 "optional". Making all versions of the dependency optional means that if your installation fails for a legitimate reason, it will silently skip installation and you will be missing a dependency you really need.
osfield in package.json, but that doesn't allow you to swap out dependencies based on current platform -- it just declares what platforms a package is whitelisted/blacklisted on. For example, this property inpackage.json:"os" : [ "!win32", "darwin" ]means "this package will not run in windows but will run on macs". Unfortunately, this doesn't really achieve what you're asking for. – smithclay Mar 5 '13 at 18:29osfield. – Chris Vandevelde Jul 16 '14 at 19:31