Npm install canvas error


#1

When i try to install canvas in my application by executing the command

npm install canvas

it shows following error

canvas@1.6.5 install /root/PhotoEditor/node_modules/canvas
node-gyp rebuild
make: Entering directory '/root/PhotoEditor/node_modules/canvas/build’
SOLINK_MODULE(target) Release/obj.target/canvas-postbuild.node
COPY Release/canvas-postbuild.node
CXX(target) Release/obj.target/canvas/src/Canvas.o
In file included from …/src/Canvas.cc:8:0:
…/src/PNG.h: In function ‘cairo_status_t canvas_write_png(cairo_surface_t*, png_rw_ptr, void*)’:
…/src/PNG.h:73:20: warning: variable ‘status’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Wclobbered]
cairo_status_t status = CAIRO_STATUS_SUCCESS;
^~~~~~
CXX(target) Release/obj.target/canvas/src/CanvasGradient.o
CXX(target) Release/obj.target/canvas/src/CanvasPattern.o
In file included from …/src/CanvasPattern.cc:9:0:
…/src/Image.h:19:21: fatal error: gif_lib.h: No such file or directory
#include <gif_lib.h>
^
compilation terminated.
canvas.target.mk:121: recipe for target ‘Release/obj.target/canvas/src/CanvasPattern.o’ failed
make: *** [Release/obj.target/canvas/src/CanvasPattern.o] Error 1
make: Leaving directory '/root/PhotoEditor/node_modules/canvas/build’
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack at emitTwo (events.js:125:13)
gyp ERR! stack at ChildProcess.emit (events.js:213:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:197:12)
gyp ERR! System Linux 4.6.0-kali1-amd64
gyp ERR! command “/usr/local/bin/node” “/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js” "rebuild"
gyp ERR! cwd /root/PhotoEditor/node_modules/canvas
gyp ERR! node -v v8.0.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
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.
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! /root/.npm/_logs/2017-06-20T15_34_38_312Z-debug.log

Anyhelp thanks…:slight_smile:


#2

This has nothing to do with Ionic, so you should probably report this at https://github.com/Automattic/node-canvas/issues


#3

sorry for the wrong heading.:expressionless:

sudo apt-get install libcairo2-dev libjpeg-dev libgif-dev

before installing canvas we have to install cairo dependencies and their libraries…then after we have to execute this command

npm install canvas

this solved my issue…

Thanks.:slight_smile: