c++node.jsnode-gypnode.js-addonplatform-specific

node-gyp platform specific addon


Is it possible to specify that a certain native addon is only meant to be build for a certain platform (e.g: win32)?

Currently I have a C++ addon that makes use of the Windows API, but node-gyp attempts to build that for UNIX based systems as well.

I've been searching in node-gyp documentation and NodeJS C/C++ addon documentation section without any luck.


Solution

  • Yes.

    You can add an "os" section to your package.json to restrict which platforms your addon is compatible with.

    Here is the OS package.json documentation.