Title: How to reference node_api.h properly since it was removed? · Issue #882 · nodejs/node-addon-api · GitHub
Open Graph Title: How to reference node_api.h properly since it was removed? · Issue #882 · nodejs/node-addon-api
X Title: How to reference node_api.h properly since it was removed? · Issue #882 · nodejs/node-addon-api
Description: 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 ...
Open Graph Description: 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 w...
X Description: 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 recommend...
Opengraph URL: https://github.com/nodejs/node-addon-api/issues/882
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"How to reference node_api.h properly since it was removed?","articleBody":"I apologize if this is not the right place for this but I'm not sure where the best place to start is.\r\n\r\nSince #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)?\r\n\r\nThis 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.\r\n\r\nI'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`.\r\n\r\nThis SO question has part of an answer: https://stackoverflow.com/questions/61730307/node-js-native-addons-where-is-node-api-h-located\r\n\r\nHowever it's fundamentally flawed (at least for my purposes) in two ways:\r\n - It references an absolute, OS specific, location\r\n - Untrivial to parameterize around node version\r\n\r\nI'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 the `node_api.h` header.\r\n\r\nMy 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`:\r\n\r\n```json\r\n{\r\n \"configurations\": [\r\n {\r\n \"name\": \"gcc-node\",\r\n \"includePath\": [\r\n \"${workspaceFolder}/node_modules/node-addon-api\",\r\n \"${config:local.node-gyp.node-cache}/include/node\"\r\n ]\r\n }\r\n ],\r\n \"version\": 4\r\n}\r\n```\r\nUser Settings\r\n```settings.json\r\n{\r\n \"local.node-gyp.node-cache\": \"C:/Users/\u003cUserName\u003e/AppData/Local/node-gyp/Cache/\u003cNodeVersion\u003e\"\r\n}\r\n```\r\n\r\nBut I feel like there should be something better than this...\r\n\r\nThanks for the look! Cheers!","author":{"url":"https://github.com/cinderblock","@type":"Person","name":"cinderblock"},"datePublished":"2021-01-21T02:23:45.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/882/node-addon-api/issues/882"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c0ee4308-fb6a-843f-0e73-277164874cdb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E8FC:E2378:52207EC:722DA5A:6A4F7763 |
| html-safe-nonce | f3de177e9e769899d6ff4e3c0f449e2b6101f1ba49d5d936687a07cf3df6e4e6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOEZDOkUyMzc4OjUyMjA3RUM6NzIyREE1QTo2QTRGNzc2MyIsInZpc2l0b3JfaWQiOiI0OTczNDgxNjA5ODIwODYyMzA3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 34a0a05e296a4b752fe59e40d5268d9178c28549a3095fea663ef467becea42c |
| hovercard-subject-tag | issue:790624765 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node-addon-api/882/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1c3ad937cda0e3977f111009865f3c19414435d41e9c31e6e7ff8d7b749b5f1b/nodejs/node-addon-api/issues/882 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1c3ad937cda0e3977f111009865f3c19414435d41e9c31e6e7ff8d7b749b5f1b/nodejs/node-addon-api/issues/882 |
| og:image:alt | 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 w... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | cinderblock |
| hostname | github.com |
| expected-hostname | github.com |
| None | b92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node-addon-api git https://github.com/nodejs/node-addon-api.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 81384578 |
| octolytics-dimension-repository_nwo | nodejs/node-addon-api |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81384578 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node-addon-api |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4b249b445842943ed31549e027f57a8ade9881ed |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width