Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js native addons: where is node_api.h located?

I'm trying to create a native addon for Node.js and when I include

#include <napi.h>

The Intelli Sense of VS Code says that it cannot detect where node_api.h is located (it's included by napi.h).

node-gyp build works well and it compiles. But I do not understand where is that header in the system and where node-gyp gets it from? I need to add the path to the Intelli Sense options and to better understand the process of building in general.

I'm playing with this code example.

like image 851
RussCoder Avatar asked May 11 '20 12:05

RussCoder


1 Answers

I have run a full search on disk C (I'm on Windows 10), and found out that the header file node_api.h is located in

C:\Users\<UserName>\AppData\Local\node-gyp\Cache\<NodeVersion>\include\node

as well as other headers like v8.h.

If you delete that folder, node-gyp build no longer works. node-gyp configure downloads all headers again and restores the above mentioned folder.

like image 131
RussCoder Avatar answered Oct 10 '22 12:10

RussCoder