-
Notifications
You must be signed in to change notification settings - Fork 465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to reference node_api.h properly since it was removed? #882
Comments
In terms of the headers the best place currently is to get it from the node headers tarball, for example: https://nodejs.org/dist/v14.15.4/node-v14.15.4-headers.tar.xz. This is what is used when addons are built when they are installed through npm. We are also discussing the possibility of distributing it separately through an npm in #855 |
The location referenced in the answers there are reliant on node-gyp having already run and downloaded and unpacked the headers tarball (e.g. in the process of installing the module).
Binary distributions from nodejs.org do contain the
For releases from nodejs.org the URL to the matching headers tarball is in
|
@cinderblock just wondering if that answered your question and this can be closed? |
I apologize if this is not the right place for this but I'm not sure where the best place to start is.
Since #643 removed
external-napi/node_api.h
from published versions, what is the recommended way to have IntelliSense (and other code linters/hinters) "see" that file (or, really, the right one)?This is a similar problem for the node-addon-api header files that is usually solved with something like this:
node -p "require('node-addon-api').include"
. For my purposes, I've noticed that this path is always${workspaceFolder}/node_modules/node-addon-api
so I'm using that for now.I've been looking for a way to consistently setup developers' environments to point to the real
node_api.h
that's currently in use. Specifically, I'm interested in setting up VS Code for this problem with.vscode/c_cpp_properties.json#configurations[0].includePath
.This SO question has part of an answer: https://stackoverflow.com/questions/61730307/node-js-native-addons-where-is-node-api-h-located
However it's fundamentally flawed (at least for my purposes) in two ways:
I've tried things like
npm i node
to see if the locally installed version has the header file that I can reference. Alas the binary distribution of Node doesn't include thenode_api.h
header.My current best solution is to instruct developers to put the path for their system that matches the SO answer into their local user configuration files and then having something like this in the committed
.vscode/c_cpp_properties.json
:User Settings
But I feel like there should be something better than this...
Thanks for the look! Cheers!
The text was updated successfully, but these errors were encountered: