d_inevitable d_inevitable - 1 year ago 83
Node.js Question

Add include dir for node gyp

I am deploying a node-js app to heroku that requires the npm package imagemagic-native.

I made the buildpack install

and export the include path:

export INCLUDE_PATH="$BUILD_DIR/.apt/usr/include:$INCLUDE_PATH"

Upon installing the
package with
npm install
, node-gyp is invoked to compile it's binaries. However I get this error:

remote: > imagemagick-native@1.7.0 install /tmp/build_720834c3a32b65d69ae603d7c618e20f/node_modules/imagemagick-native
remote: > node-gyp rebuild
remote: make: Entering directory `/tmp/build_720834c3a32b65d69ae603d7c618e20f/node_modules/imagemagick-native/build'
remote: CXX(target) Release/obj.target/imagemagick/src/imagemagick.o
remote: In file included from ../src/imagemagick.cc:9:
remote: ../src/imagemagick.h:1:22: warning: Magick++.h: No such file or directory

This suggests that gcc doesn't see the header files for
, because
is not available to it.

How can I make
npm install
add the path to the list of
that node-gyp uses?

More detail about my use case is here: Using Magick++ in a node.js application on heroku

Answer Source


setting the environment variable CXX=/path/to/g++ -Ipath/to/include

and then restarting the process. If you're using bash this is done by

export CXX="/path/to/g++ -Ipath/to/include"

/path/to/include being where the missing header Magick++.h is located

if that doesn't work you may manually have to set CXX to include the -I in the makefile at /tmp/build_720834c3a32b65d69ae603d7c618e20f/node_modules/imagemagick-native/build then cding into that directory and calling make.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download