Heroku 构建依赖项安装失败
Posted
技术标签:
【中文标题】Heroku 构建依赖项安装失败【英文标题】:Heroku build failing on dependency install 【发布时间】:2020-10-17 07:39:54 【问题描述】:Node Canvas 没有安装在 Heroku 版本上,尽管它在我自己的 PC 上运行良好。我在 nodejs 版本 12.16.3 上。我在任何地方都找不到解决方案。
Canvas 是必须的,在 Heroku 之前我从未见过这个错误。这是 Heroku 的问题还是我的包/包锁定文件的问题?
如果你需要的话,我的 Discord 是 Tom Becker#0590。
这是我的构建日志:
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_ENV=production
NODE_MODULES_CACHE=true
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): 12.x
engines.npm (package.json): unspecified (use default)
Resolving node version 12.x...
Downloading and installing node 12.18.1...
Using default npm version: 6.14.5
-----> Installing dependencies
Installing node modules (package.json + package-lock)
> deasync@0.1.19 install /tmp/build_282e7f55032649968878bcdef8821199/node_modules/deasync
> node ./build.js
`linux-x64-node-12` exists; testing
Binary is fine; exiting
> canvas@2.6.1 install /tmp/build_282e7f55032649968878bcdef8821199/node_modules/canvas
> node-pre-gyp install --fallback-to-build
Package pangocairo was not found in the pkg-config search path.
Perhaps you should add the directory containing `pangocairo.pc'
to the PKG_CONFIG_PATH environment variable
No package 'pangocairo' found
gyp: Call to 'pkg-config pangocairo --libs' returned exit status 1 while in binding.gyp. 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/build_282e7f55032649968878bcdef8821199/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Linux 4.4.0-1073-aws
gyp ERR! command "/tmp/build_282e7f55032649968878bcdef8821199/.heroku/node/bin/node" "/tmp/build_282e7f55032649968878bcdef8821199/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/tmp/build_282e7f55032649968878bcdef8821199/node_modules/canvas/build/Release/canvas.node" "--module_name=canvas" "--module_path=/tmp/build_282e7f55032649968878bcdef8821199/node_modules/canvas/build/Release" "--napi_version=6" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72"
gyp ERR! cwd /tmp/build_282e7f55032649968878bcdef8821199/node_modules/canvas
gyp ERR! node -v v12.18.1
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/tmp/build_282e7f55032649968878bcdef8821199/.heroku/node/bin/node /tmp/build_282e7f55032649968878bcdef8821199/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/tmp/build_282e7f55032649968878bcdef8821199/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/tmp/build_282e7f55032649968878bcdef8821199/node_modules/canvas/build/Release --napi_version=6 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/tmp/build_282e7f55032649968878bcdef8821199/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:315:20)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
node-pre-gyp ERR! System Linux 4.4.0-1073-aws
node-pre-gyp ERR! command "/tmp/build_282e7f55032649968878bcdef8821199/.heroku/node/bin/node" "/tmp/build_282e7f55032649968878bcdef8821199/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /tmp/build_282e7f55032649968878bcdef8821199/node_modules/canvas
node-pre-gyp ERR! node -v v12.18.1
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok
Failed to execute '/tmp/build_282e7f55032649968878bcdef8821199/.heroku/node/bin/node /tmp/build_282e7f55032649968878bcdef8821199/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/tmp/build_282e7f55032649968878bcdef8821199/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/tmp/build_282e7f55032649968878bcdef8821199/node_modules/canvas/build/Release --napi_version=6 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! canvas@2.6.1 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the canvas@2.6.1 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.3BVoV/_logs/2020-06-26T16_20_37_894Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
【问题讨论】:
在 pkg-config 搜索路径中找不到包 pangocairo。也许您应该将包含 `pangocairo.pc' 的目录添加到 PKG_CONFIG_PATH 环境变量 No package 'pangocairo' found 【参考方案1】:预构建的软件包似乎存在一些问题。它可以根据 Node.js 版本工作,对我有用的最新版本是 14.14.0
所以尝试在你的 package.json
中设置它
更多关于这里https://github.com/Automattic/node-canvas/issues/1563#issuecomment-625149050
在最近发布https://nodejs.org/en/blog/release/v15.0.1/987654322@后,我的构建从 Node v14.14.0 切换到 v15.0.1 后,我遇到了类似的问题
【讨论】:
【参考方案2】:除了使用兼容的node.js
版本(我正在使用13.3.0
)之外,我还做了两件事:
node-pre-gyp
,它似乎正确地预先构建了所有东西npm install node-pre-gyp@7.1.2
将heroku堆栈设置为18:
heroku stack:set heroku-18
【讨论】:
以上是关于Heroku 构建依赖项安装失败的主要内容,如果未能解决你的问题,请参考以下文章
添加 cocoapods 依赖项后,Fastlane 健身房失败
安装依赖项时如何解决“'websocket-driver'的完整性检查失败”错误?
Jeddict 插件安装失败 - Apache Netbeans 12 - 缺少“Maven Projects”插件依赖项