You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am writing a large C++ addon and would like to use the node-addon-api but it lacks some of the "C" API's features (thread safe functions in particular) so I need to fallback on the "C" N-API.
Unfortunately, the node-addon-api bundles a too old version of "node_api.h", so I can't mix and match.
Could node-addon-api be updated to use latest N-API C header files ?
@extmchristensen you only need the bundled N-API implementation if you're planning on building against a version of Node.js which does not itself have an implementation of N-API (i.e. pre-6.14.2, IIRC). node-addon-api avoids using the built-in headers if the version of Node.js against which it's building has its own headers.
The reason node-addon-api does not have thread-safe function is not that it's missing from the bundled headers, but that it hasn't been implemented in the C++ wrapper – however, as you noticed, we have #442 that seeks to implement it.
@extmchristensen node-addon-api is needed if you wish to use Napi::* in your native addon. On recent versions of Node.js, src/node_api.h, src/node_api.cc and all other files under node-addon-api's src/ directory are unneeded, because they are part of Node.js itself.
What versions of Node.js do you plan to support with your native addon?
@extmchristensen for this range of Node.js versions N-API is built-in. Therefore node-addon-api will not compile the version of N-API it ships. This means that the files in its src/ subdirectory are OK to be out-of-date because they will not be compiled and linked into your add-on. Rather, your addon will link to the N-API implementation provided by Node.js.
Activity
legendecas commentedon Mar 29, 2019
AFAIK, you could directly include
node-api.hin/usr/local/include/node(assuming installed node.js with headers).gabrielschulhof commentedon Mar 29, 2019
@extmchristensen you only need the bundled N-API implementation if you're planning on building against a version of Node.js which does not itself have an implementation of N-API (i.e. pre-6.14.2, IIRC). node-addon-api avoids using the built-in headers if the version of Node.js against which it's building has its own headers.
The reason node-addon-api does not have thread-safe function is not that it's missing from the bundled headers, but that it hasn't been implemented in the C++ wrapper – however, as you noticed, we have #442 that seeks to implement it.
gabrielschulhof commentedon Apr 1, 2019
@extmchristensen node-addon-api is needed if you wish to use
Napi::*in your native addon. On recent versions of Node.js,src/node_api.h,src/node_api.ccand all other files under node-addon-api'ssrc/directory are unneeded, because they are part of Node.js itself.What versions of Node.js do you plan to support with your native addon?
gabrielschulhof commentedon Apr 11, 2019
@extmchristensen for this range of Node.js versions N-API is built-in. Therefore node-addon-api will not compile the version of N-API it ships. This means that the files in its
src/subdirectory are OK to be out-of-date because they will not be compiled and linked into your add-on. Rather, your addon will link to the N-API implementation provided by Node.js.gabrielschulhof commentedon Sep 23, 2019
This issue, along with #509 needs to be closed when Node.js v8.x goes out of scope and we will have removed the src/-provided implementation of N-API.
remove N-API implementation
remove N-API implementation and v8.x support
remove N-API implementation, v6.x and v8.x support
remove N-API implementation, v6.x and v8.x support
remove N-API implementation, v6.x and v8.x support
remove N-API implementation, v6.x and v8.x support
remove N-API implementation, v6.x and v8.x support
remove N-API implementation, v6.x and v8.x support