跳到主要内容

Canvas 2.2.0 install broken

安装 canvas 相关依赖发生错误:

Package pixman-1 was not found in the pkg-config search path
Version 2.2.0 upgrade is broken while previous version (2.1.0) works perfectly.

Error:
../src/CanvasRenderingContext2d.cc:1810:12: warning: unused variable ‘iso’ [-Wunused-variable]
Isolate *iso = Isolate::GetCurrent();
^~~
canvas.target.mk:134: recipe for target 'Release/obj.target/canvas/src/CanvasRenderingContext2d.o' failed
make: *** [Release/obj.target/canvas/src/CanvasRenderingContext2d.o] Error 1
make: Leaving directory '/home/nodejs/cvcback-development/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:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:192:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.15.0-1021-aws
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/home/nodejs/cvcback-development/node_modules/canvas/build/Release/canvas-prebuilt.node" "--module_name=canvas-prebuilt" "--module_path=/home/nodejs/cvcback-development/node_modules/canvas/build/Release" "--node_abi_napi=node-v51" "--napi_build_version=0" "--node_napi_label=node-v51"
gyp ERR! cwd /home/nodejs/cvcback-development/node_modules/canvas
gyp ERR! node -v v7.6.0
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/home/nodejs/cvcback-development/node_modules/canvas/build/Release/canvas-prebuilt.node --module_name=canvas-prebuilt --module_path=/home/nodejs/cvcback-development/node_modules/canvas/build/Release --node_abi_napi=node-v51 --napi_build_version=0 --node_napi_label=node-v51' (1)
node-pre-gyp ERR! stack at ChildProcess. (/home/nodejs/cvcback-development/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:106:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:192:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:890:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
node-pre-gyp ERR! System Linux 4.15.0-1021-aws
node-pre-gyp ERR! command "/usr/local/bin/node" "/home/nodejs/cvcback-development/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /home/nodejs/cvcback-development/node_modules/canvas
node-pre-gyp ERR! node -v v7.6.0
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok

解决办法

安装编译相关依赖

sudo apt install libpixman-1-dev libcairo2-dev libpango1.0-dev libjpeg8-dev libgif-dev

参考