画布节点模块和Google Cloud Functions

时间:2017-05-19 10:40:33

标签: node.js lambda google-cloud-functions

我正在尝试创建一个从文本生成图像的Google Cloud功能。

我使用了this Canvas节点模块

(必须在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

1 个答案:

答案 0 :(得分:-1)

在Ubuntu 16.04上,按照此处的说明安装依赖项,我能够解决类似的问题:https://www.npmjs.com/package/canvas