Skip to content
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

C1083: Cannot open include file: 'napi.h': No such file or directory #183

Open
SurienDG opened this issue May 10, 2021 · 4 comments
Open

Comments

@SurienDG
Copy link

SurienDG commented May 10, 2021

I get an error about not being able to find napi.h on Windows.

This only occurs when I use "include_dirs": ["<!@(node -p \"require('node-addon-api').include_dir\")"] versus "include_dirs": ["<!@(node -p \"require('node-addon-api').include\")"] (I was trying to use the former because in the index.js file it says the latter is deprecated.

The only difference I noticed is that inside the in the index.js file in the repo we have the include path in escaped quotes.

I've tried doing this as an experiment in another bindings repo and I found if I add the quotes to the include path it works versus without.

include: `"${__dirname}"`

versus

 include: `${__dirname}`

(The second one gives the error)

[Edit]: I just tried this on Linux (using WSL) and seems like I have the inverse problem...

fatal error: napi.h: No such file or directory
    4 | #include "napi.h"
      |          ^~~~~~~~
compilation terminated.
@SurienDG
Copy link
Author

SurienDG commented May 10, 2021

So I found that if we simply change line 3 of index.js to

const include_dir = `"${path.relative('.', __dirname)}"`;

then it works on both platforms. Can we have this change made?

@mhdawson
Copy link
Member

@SurienDG can you submit a PR for that change?

@SurienDG
Copy link
Author

SurienDG commented May 15, 2021

@mhdawson Sure thing 😀. I added one here: nodejs/node-addon-api#1001

@mhdawson
Copy link
Member

@SurienDG thanks. For some reason the PR seems to cause failures across platforms, can you take a look.

@mhdawson mhdawson reopened this May 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants