Friday 19 May 2017

canvas node module and Google Cloud Functions

I am trying to create a Google Cloud Function that generates an image from text.

I've used this Canvas node module

(had to install these dependencies on Mac to run it locally)

brew install pkg-config cairo pango libpng jpeg giflib

My package.json looks like this:

  "dependencies": {
    "canvas": "^1.6.5"
  }

While trying to deploy it as a Function to Google cloud I am getting this error (seems like there are missing dependencies on the remote container)

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



via Amiram Shachar

No comments:

Post a Comment