画布节点模块和谷歌云函数
Posted
技术标签:
【中文标题】画布节点模块和谷歌云函数【英文标题】:canvas node module and Google Cloud Functions 【发布时间】:2017-10-19 11:01:57 【问题描述】:我正在尝试创建一个从文本生成图像的 Google Cloud 函数。
我用过thisCanvas 节点模块
(必须在 Mac 上安装这些依赖项才能在本地运行)
brew install pkg-config cairo pango libpng jpeg giflib
我的 package.json 看起来像这样:
"dependencies":
"canvas": "^1.6.5"
在尝试将其作为函数部署到 Google 云时出现此错误(似乎缺少远程容器上的依赖项)
Copying file:///var/folders/rq/jqlbr35d6gg3_bjhwgzdjm3m0000gn/T/tmpsuL8lN/fun.zip [Content-Type=application/zip]...
- [1 files][ 722.0 B/ 722.0 B]
Operation completed over 1 objects/722.0 B.
Waiting for operation to finish...failed.
Deploying function (may take a while - up to 2 minutes)...failed.
ERROR: (gcloud.beta.functions.deploy) OperationError: code=3, message=Build failed: exit status 1
> canvas@1.6.5 install /workspace/node_modules/canvas
> node-gyp rebuild
./util/has_lib.sh: 31: ./util/has_lib.sh: pkg-config: not found
gyp: Call to './util/has_lib.sh freetype' returned exit status 0 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 (/nodejs/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.4.0-78-generic
gyp ERR! command "/nodejs/bin/node" "/nodejs/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /workspace/node_modules/canvas
gyp ERR! node -v v6.9.1
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm WARN img@1.0.0 No description
npm WARN img@1.0.0 No repository field.
npm ERR! Linux 4.4.0-78-generic
npm ERR! argv "/nodejs/bin/node" "/nodejs/bin/npm" "--global-style" "--production" "--fetch-retries=5" "--fetch-retry-factor=2" "--fetch-retry-mintimeout=1000" "install" "/workspace"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! canvas@1.6.5 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the canvas@1.6.5 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the canvas package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs canvas
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls canvas
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /workspace/npm-debug.log
【问题讨论】:
您能找到解决方案吗?找到替代方案了吗?任何帮助,将不胜感激。谢谢! 你在 App-Engine 上试过了吗?我在那里有类似的问题。这些盒子上似乎缺少一些编译时依赖项:( 你解决了吗?我们也有类似的要求。 【参考方案1】:在 Ubuntu 16.04 上,我可以按照此处的说明安装依赖项来解决类似问题:https://www.npmjs.com/package/canvas
【讨论】:
我正在尝试将其上传到 Google Cloud Functions以上是关于画布节点模块和谷歌云函数的主要内容,如果未能解决你的问题,请参考以下文章