Building native add-ons

Open Enterprise SDK for Node.js supports native add-ons, which loads dynamically linked shared objects that are written in C/C++ or PL/I into your Node.js applications. With this ability, you are no longer confined to what you can write with JavaScript and Node.js APIs, but can extend your applications to tap existing native drivers, libraries, services, and so on.

Before you build native add-ons, you must install all of the following tools or utilities.
  • Python 3.8.2 or later 3.x releases
  • Make 4.1 or later
You can build or install native add-on packages with the following commands:
$ npm install .                # To build in package directory
$ npm install <package name>   # To install the specified package from npmjs

Building C/C++ native add-ons

Open Enterprise SDK for Node.js includes a 64-bit C/C++ compiler (njsc/njsc++) with C++14 language support to facilitate the compilation of native add-on modules.

You must install the C/C++ compiler that you downloaded with Open Enterprise SDK for Node.js to build C/C++ native add-ons.

Building PL/I native add-ons

PL/I source files with the .pli extension can be added to the sources section of the node-gyp binding.gyp file. For example,
"sources": [ "plibinding.cc", "num.pli" ]

PL/I source files that are specified in such a way are automatically compiled and linked, similar to C/C++ source files.

node-gyp assumes the Enterprise PL/I for z/OS compiler, specifically, the pli compiler command. To override this, you can export the PLI environment variable to point to the PLI compiler of your choice.

Related reference