3

I am trying to learn how to use C and/or C++ libraries inside NodeJS.

But it is somewhat confusing the many different tools and approaches, and the relation between them.

What is the difference between NodeJS N-API and "nan", and what is the role played by node-gyp and/or cmake-js.

Paulo Coghi
  • 13,724
  • 14
  • 68
  • 90

1 Answers1

4

If you are starting a fresh development that involve building native module, then N-API could be an excellent choice. The N-API is the node.js core C API to interact with underlying JavaScript engine (it is relatively a new addition). It provides Application Binary Interface (ABI) stability guarantee across node.js versions.

While I was learning the N-API, a GitHub repository has been created with short note and example. Hope this may help you to get understanding the evolution history and a jump start for creating C/C++ native modules. https://github.com/msatyan/MyNodeC

Satyan
  • 1,346
  • 8
  • 15
  • Thanks for the answer! Since `node-gyp` is mentioned in the repository you linked, can you elaborate about `cmake-js` vs `node-gyp`? – Paulo Coghi Oct 02 '19 at 08:00
  • If you are a C++ developer,familiar with cmake, use cmake-js; otherwise use node-gyp. – msg Mar 26 '20 at 14:34