问题
I'm trying to push a Node app to heroku, but I am using imagemagick-native and it seems that Heroku is having an issue with Magick++ - I've tried using custom build packs but can't seem to find one that supports Magick++. (1) Is this the issue (2) Is there any solution to run Magick++ on Heorku?
-----> Node.js app detected
-----> Resolving engine versions
Using Node.js version: 0.10.20
Using npm version: 1.3.11
-----> Fetching Node.js binaries
-----> Vendoring node into slug
-----> Installing dependencies with npm
npm WARN package.json upload@0.1.3 'repositories' (plural) Not supported.
npm WARN package.json Please pick one as the 'repository' field
> bson@0.2.2 install /tmp/build_d2a98573-34b8-42d9-91ff-81c4ca84feb9/node_modules/mongoose/node_modules/mongodb/node_modules/bson
> (node-gyp rebuild 2> builderror.log) || (exit 0)
make: Entering directory `/tmp/build_d2a98573-34b8-42d9-91ff-81c4ca84feb9/node_modules/mongoose/node_modules/mongodb/node_modules/bson/build'
CXX(target) Release/obj.target/bson/ext/bson.o
SOLINK_MODULE(target) Release/obj.target/bson.node
SOLINK_MODULE(target) Release/obj.target/bson.node: Finished
COPY Release/bson.node
make: Leaving directory `/tmp/build_d2a98573-34b8-42d9-91ff-81c4ca84feb9/node_modules/mongoose/node_modules/mongodb/node_modules/bson/build'
> kerberos@0.0.3 install /tmp/build_d2a98573-34b8-42d9-91ff-81c4ca84feb9/node_modules/mongoose/node_modules/mongodb/node_modules/kerberos
> (node-gyp rebuild 2> builderror.log) || (exit 0)
make: Entering directory `/tmp/build_d2a98573-34b8-42d9-91ff-81c4ca84feb9/node_modules/mongoose/node_modules/mongodb/node_modules/kerberos/build'
SOLINK_MODULE(target) Release/obj.target/kerberos.node
SOLINK_MODULE(target) Release/obj.target/kerberos.node: Finished
COPY Release/kerberos.node
make: Leaving directory `/tmp/build_d2a98573-34b8-42d9-91ff-81c4ca84feb9/node_modules/mongoose/node_modules/mongodb/node_modules/kerberos/build'
> imagemagick-native@0.2.8 install /tmp/build_d2a98573-34b8-42d9-91ff-81c4ca84feb9/node_modules/imagemagick-native
> node-gyp rebuild
/bin/sh: Magick++-config: not found
gyp: Call to 'Magick++-config --ldflags --libs' returned exit status 127. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/tmp/node-npm-k25M/node_modules/node-gyp/lib/configure.js:424:16)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Linux 3.8.11-ec2
gyp ERR! command "node" "/tmp/node-npm-k25M/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /tmp/build_d2a98573-34b8-42d9-91ff-81c4ca84feb9/node_modules/imagemagick-native
gyp ERR! node -v v0.10.20
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok
npm ERR! weird error 1
npm ERR! not ok code 0
! Failed to rebuild dependencies with npm
! Push rejected, failed to compile Node.js app
回答1:
I've made some progress on this:
Use the multi buildpack:
heroku config:set BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git
So that it can load the apt-buildpack in addition to the nodejs one. List your builpacks in .buildpacks
:
https://github.com/ddollar/heroku-buildpack-apt.git
https://github.com/heroku/heroku-buildpack-nodejs.git
Now install libmagick++-dev
through apt by listing it in a file called Aptfile
.
Now if you include imagemagick-native in your package.json
:
"dependencies": {
"imagemagick-native": "1.7.0"
}
It will start compiling. And although $CPATH
is set properly by the APT package, node-gyp
somehow doesn't seem to forward it to gcc.
This causes the following error:
remote: > imagemagick-native@1.7.0 install /tmp/build_720834c3a32b65d69ae603d7c618e20f/node_modules/imagemagick-native
remote: > node-gyp rebuild
remote:
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
So it doesn't solve the problem yet, but I think it's on the right track. Still trying to figure out what's up with node-gyp.
Update
To workaround that problem fork the nodejs buildpack and add the following lines to the top of bin/compile
:
path=`echo "$INCLUDE_PATH" | cut -d : -f 1`
export CXX="`which g++` -I$path/ImageMagick"
Works on cedar-14
. For the deprecated cedar
you would need to use imagemagick-native v1.22.
来源:https://stackoverflow.com/questions/19612789/using-magick-in-a-node-js-application-on-heroku