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

node-gyp build can't find node.h #519

Closed
asha451 opened this issue Oct 24, 2014 · 14 comments
Closed

node-gyp build can't find node.h #519

asha451 opened this issue Oct 24, 2014 · 14 comments

Comments

@asha451
Copy link

asha451 commented Oct 24, 2014

Environment:
Lubuntu 14.04.1 LTS on a 32bit VM
bitnami Meanstack-2.6.4-0
I've run npm install build-essential to make sure I have python 2.7, make, etc.

While following a tutorial on creating an add-on for node, the command "node-gyp build" failed, unable to find the "node.h" file. The following is the console log:

gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | ia32
gyp info spawn make
make: Entering directory `/home/nnnnn/Desktop/node-cpp-rcf/build'
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  ACTION Regenerating Makefile
make: Leaving directory `/home/nnnnn/Desktop/node-cpp-rcf/build'
make: Entering directory `/home/nnnnn/Desktop/node-cpp-rcf/build'
  CXX(target) Release/obj.target/nodecpptest/main.o
../main.cpp:1:18: fatal error: node.h: No such file or directory
 #include <node.h>
                  ^
compilation terminated.
make: *** [Release/obj.target/nodecpptest/main.o] Error 1
make: Leaving directory `/home/nnnnn/Desktop/node-cpp-rcf/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/share/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:810:12)
gyp ERR! System Linux 3.13.0-37-generic
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "build"
gyp ERR! cwd /home/nnnnn/Desktop/node-cpp-rcf
gyp ERR! node -v v0.10.33
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok 

Before this, I had to copy the common.gypi file to the expected directory in order to make the "node-gyp configure" command work. (re-install of node-gyp didn't work)

Am I seeing a pattern? How do I tell node-gyp where to find my libraries/includes?
node-gyp configure --nodedir="/home/nnnnn/meanstack-2.6.4-0/nodejs/include/node" was something that I found worked for the configure command, but not for the build command.

Thank you kindly for any assistance.

@asha451
Copy link
Author

asha451 commented Oct 25, 2014

So I setup a new VM with the same lubuntu and installed all the necessary packages from scratch... and it all works. Still, I really want to understand why and what the best solution is. A complete re-install feels like a really impractical approach to the many problems we face as coders. And it doesn't make me feel like I've learned anything. So for the sake of education (mine and those with similar problems), what can be done?

My suspicion is that somewhere along the line, node-gyp (or maybe Make) has been given the wrong set of assumptions, and that there is a symlink or path alteration that needs to happen.

I apologize if this is question would be really more appropriate on askubuntu or some other more general site, but with any luck, a clear answer may shunt these questions away from this site in the future.

Thanks :)

@DiegoRBaquero
Copy link

Did you ever get the answer @asha451 ?

@NutWatcher
Copy link

I get same problem .

@cccRaim
Copy link

cccRaim commented Sep 26, 2017

I have the same problem!

@gibfahn
Copy link
Member

gibfahn commented Sep 26, 2017

Try node-gyp rebuild, it should download the headers to ~/.node-gyp.

@cccRaim
Copy link

cccRaim commented Sep 27, 2017

I use nvm, so I should make a soft link to /usr/local/include/node

@refack
Copy link
Contributor

refack commented Sep 27, 2017

@cccRaim could you post the error message you are getting (preferably also the log).
Is it exactly the same as the OP (i.e. [email protected] and [email protected])?
If soft-linking solves the problem, could you elaborate what's the link and what's the target?

@cccRaim
Copy link

cccRaim commented Sep 27, 2017

@refack

> [email protected] preinstall /Users/awalong/WebstormProjects/test/node_modules/php-pack
> node-gyp rebuild

  CXX(target) Release/obj.target/phppack/pack.o
../pack.cc:1:10: fatal error: 'node/node.h' file not found
#include <node/node.h>
         ^~~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/phppack/pack.o] Error 1

[email protected]
[email protected]

You can see the same problem, can't found the file in c language file, this problem is related to C's include rule, on the other hand, it means your include DIRs don't have the file (such as node/node.h).
I use OS, the C include DIR is /usr/local/include, so I make a soft link. (I use nvm)
ln -s /Users/{your username}/.nvm/versions/node/v8.1.4/include/node /usr/local/include/node

@refack
Copy link
Contributor

refack commented Sep 27, 2017

@cccRaim thank you for following up.
I'll see if we can incorporate some detection logic to auto solve this...

@bnoordhuis
Copy link
Member

@cccRaim You should file an issue against php-pack because those imports are simply wrong. It's not a node-gyp bug.

I'll close this out. If you (generic you) run into a similar-but-not-identical issue, please file a new issue and include build output.

@cccRaim
Copy link

cccRaim commented Sep 27, 2017

@bnoordhuis wait. it's not my issue. w(゚Д゚)w
I just post a thinking of this issue

@refack
Copy link
Contributor

refack commented Sep 27, 2017

@cccRaim the original issue has been open for 3 years (and 3 major node-gyp versions ;) it's time was due anyway...

Cross-ref https://github.com/acgpiano/php-pack/pull/2

@jonhoo
Copy link

jonhoo commented May 24, 2018

I wonder if this might be fixed when the fix for nodejs/node#20921 lands

@bnoordhuis
Copy link
Member

@jonhoo No, completely unrelated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants