5

我正在尝试将 Node 应用程序推送到 heroku,但我使用的是imagemagick-native,而且 Heroku 似乎遇到了 Magick++ 的问题 - 我尝试使用自定义构建包,但似乎找不到支持 Magick++ 的包. (1)这是问题吗(2)有什么解决方案可以在 Heorku 上运行 Magick++ 吗?

-----> 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
4

1 回答 1

0

我在这方面取得了一些进展:

使用多构建包

heroku config:set BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git

这样它就可以加载除了 nodejs 之外的apt-buildpack 。列出您的构建包.buildpacks

https://github.com/ddollar/heroku-buildpack-apt.git
https://github.com/heroku/heroku-buildpack-nodejs.git

现在libmagick++-dev通过 apt 将其列在一个名为Aptfile.

现在,如果您将 imagemagick-native 包含在您的package.json

"dependencies": {
    "imagemagick-native": "1.7.0"
}

它将开始编译。尽管$CPATH由 APT 包正确设置,node-gyp但似乎并没有将其转发给 gcc。

这会导致以下错误:

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

所以它还没有解决问题,但我认为它在正确的轨道上。仍在试图弄清楚 node-gyp 是怎么回事。


更新

要解决该问题,请分叉 nodejs buildpack 并将以下行添加到顶部bin/compile

path=`echo "$INCLUDE_PATH" | cut -d : -f 1`
export CXX="`which g++` -I$path/ImageMagick"

适用于cedar-14. 对于已弃用的cedar,您需要使用 imagemagick-native v1.22。

于 2015-02-04T21:10:02.917 回答