Search code examples
node.jsnode.js-addon

Share Node Addons


I have created a node addon and I am able to use it without any issues. I want to share the addon to other developers. What is the best way to share the addon so that other developers can use the same. Is it enough to share .node file only ?


Solution

  • In general, a native add-on can be distributed like any other package on npm

    However, there are some things to be aware of:

    1. *.node files are shared libraries, so they are bound to a specific target platform. Your *.node file would only be suitable for the platform you built it for. For broader use, you'd have to build a dedicated *.node file for ever platform you want to support.

    2. Used 3rd-party libraries: If your native add-on uses any 3rd-party libraries, you have to ensure that these libraries are present on the target system and can be found. You'd have to ship all required libs (and take care of during build) if you want to make sure they are available. Alternatively: Hard requirements for your package

    3. Native add-on type: Depending on how you built your native add-on (e.g. NAN or N-API), your add-on might be suitable for certain node versions.

    3.1. N-API: Your native add-on is usable with various node versions (see this overview)

    3.2. NAN: NAN add-ons are built for specific node ABI versions, so an add-on built against a certain node ABI (e.g. 64) won't be usable with another node ABI (e.g. 56). You'd have to provide a dedicated *.node file for every node ABI you want to support

    There's some useful tooling to help distributing native add-ons: N-API docs