iamwebkalakaar
iamwebkalakaar

Reputation: 358

Google Cloud node install third party libraries Node.js

I am deploying my code on Google Cloud. Everything is working fine when testing, but when I run:

gcloud app deploy

It shows an error. Basically, I need to install Node.js canvas which requires some dependencies which I already installed on my app, but it still returns the error. Below are the logs:

Step #1: > [email protected] preinstall /app/node_modules/extract-opts/node_modules/typechecker
Step #1: > node ./cyclic.js
Step #1:
Step #1:
Step #1: > [email protected] preinstall /app/node_modules/extendr/node_modules/typechecker
Step #1: > node ./cyclic.js
Step #1:
Step #1:
Step #1: > [email protected] install /app/node_modules/canvas
Step #1: > node-gyp rebuild
Step #1:
Step #1: ./util/has_lib.sh: 31: ./util/has_lib.sh: pkg-config: not found
Step #1: gyp: Call to './util/has_lib.sh freetype' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
Step #1: gyp ERR! configure error 
Step #1: gyp ERR! stack Error: `gyp` failed with exit code: 1
Step #1: gyp ERR! stack     at ChildProcess.onCpExit (/nodejs/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:336:16)
Step #1: gyp ERR! stack     at emitTwo (events.js:126:13)
Step #1: gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
Step #1: gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
Step #1: gyp ERR! System Linux 4.4.0-116-generic
Step #1: gyp ERR! command "/nodejs/bin/node" "/nodejs/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
Step #1: gyp ERR! cwd /app/node_modules/canvas
Step #1: gyp ERR! node -v v8.10.0
Step #1: gyp ERR! node-gyp -v v3.6.2
Step #1: gyp ERR! not ok 
Step #1: npm WARN [email protected] No repository field.
Step #1: npm WARN The package reactstrap is included as both a dev and production dependency.
Step #1: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
Step #1: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
Step #1: 
Step #1: npm ERR! code ELIFECYCLE
Step #1: npm ERR! errno 1
Step #1: npm ERR! [email protected] install: `node-gyp rebuild`
Step #1: npm ERR! Exit status 1
Step #1: npm ERR! 
Step #1: npm ERR! Failed at the [email protected] install script.
Step #1: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Step #1: 
Step #1: npm ERR! A complete log of this run can be found in:
Step #1: npm ERR!     /root/.npm/_logs/2018-03-26T04_20_15_774Z-debug.log
Step #1: The command '/bin/sh -c npm install --unsafe-perm ||   ((if [ -f npm-debug.log ]; then       cat npm-debug.log;     fi) && false)' returned a non-zero code: 1
Finished Step #1
ERROR
ERROR: build step 1 "gcr.io/cloud_builders/docker@sha256:88d8c498fe61a305c35270036827752eaa7d3cc907c6092ed529d870131de440" failed: exit status 1
Step #1: 
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

ERROR: (gcloud.app.deploy) Cloud build failed. Check logs at https://console.cloud.google.com/gcr/builds/90bde4a5-cf43-4bd1-95a4-bac00edfa6e1?project=samparq-198005 Failure status: UNKNOWN: Error Response: [2] Build failed; check build logs for details

Upvotes: 3

Views: 826

Answers (1)

Manuel Perez Heredia
Manuel Perez Heredia

Reputation: 2357

The issue is documented here. I am going to paste the answer given:

Apparently we are missing cairo module (https://www.cairographics.org/) needed by canvas package, hence the installation failure. While we work through how to include the module in the base image, I found canvas-prebuilt package (https://www.npmjs.com/package/canvas-prebuilt) that does not have the installation issues. Would that work for you ?

In my case it has worked so I think it is valid. Hope it works for you as well.

Upvotes: 1

Related Questions