xbc-shim が見つからないだとかで node-canvas がインストール出来ない時
Cairo も XQuartz も入っているのに node-canvas のインストール時に失敗した時。環境は Maverics (10.9)
$ npm install canvas npm http GET https://registry.npmjs.org/canvas npm http 200 https://registry.npmjs.org/canvas npm http GET https://registry.npmjs.org/canvas/-/canvas-1.1.2.tgz npm http 200 https://registry.npmjs.org/canvas/-/canvas-1.1.2.tgz npm http GET https://registry.npmjs.org/nan npm http 200 https://registry.npmjs.org/nan npm http GET https://registry.npmjs.org/nan/-/nan-0.4.4.tgz npm http 200 https://registry.npmjs.org/nan/-/nan-0.4.4.tgz > [email protected] install /Users/nulltask/node_modules/canvas > node-gyp rebuild gyp http GET http://nodejs.org/dist/v0.10.22/node-v0.10.22.tar.gz gyp http 200 http://nodejs.org/dist/v0.10.22/node-v0.10.22.tar.gz Package xcb-shm was not found in the pkg-config search path. Perhaps you should add the directory containing `xcb-shm.pc' to the PKG_CONFIG_PATH environment variable Package 'xcb-shm', required by 'cairo', not found gyp: Call to './util/has_cairo_freetype.sh' returned exit status 0. 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 (/Users/nulltask/.brew/Cellar/node/0.10.22/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:467:16) gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17) gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:789:12) gyp ERR! System Darwin 13.0.0 gyp ERR! command "node" "/Users/nulltask/.brew/Cellar/node/0.10.22/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /Users/nulltask/node_modules/canvas gyp ERR! node -v v0.10.22 gyp ERR! node-gyp -v v0.11.0 gyp ERR! not ok npm ERR! [email protected] install: `node-gyp rebuild` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] install script. npm ERR! 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 their info via: npm ERR! npm owner ls canvas npm ERR! There is likely additional logging output above. npm ERR! System Darwin 13.0.0 npm ERR! command "/Users/nulltask/.brew/Cellar/node/0.10.22/bin/node" "/Users/nulltask/.brew/bin/npm" "install" "canvas" npm ERR! cwd /Users/nulltask npm ERR! node -v v0.10.22 npm ERR! npm -v 1.3.14 npm ERR! code ELIFECYCLE npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /Users/nulltask/npm-debug.log npm ERR! not ok code 0
$ find / -name xcb-shm.pc 2> /dev/null /opt/X11/lib/pkgconfig/xcb-shm.pc
ふむふむ。環境変数 PKG_CONFIG_PATH に /opt/X11/lib/pkgconfig を指定してみると...
$ PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig npm install canvas > [email protected] install /Users/nulltask/node_modules/canvas > node-gyp rebuild CXX(target) Release/obj.target/canvas/src/Canvas.o 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:10: ../src/CanvasPattern.h:24:9: warning: private field '_width' is not used [-Wunused-private-field] int _width, _height; ^ ../src/CanvasPattern.h:24:17: warning: private field '_height' is not used [-Wunused-private-field] int _width, _height; ^ 2 warnings generated. CXX(target) Release/obj.target/canvas/src/CanvasRenderingContext2d.o CXX(target) Release/obj.target/canvas/src/color.o CXX(target) Release/obj.target/canvas/src/Image.o CXX(target) Release/obj.target/canvas/src/ImageData.o CXX(target) Release/obj.target/canvas/src/init.o CXX(target) Release/obj.target/canvas/src/PixelArray.o CXX(target) Release/obj.target/canvas/src/FontFace.o In file included from ../src/FontFace.cc:7: ../src/FontFace.h:27:15: warning: private field '_ftFace' is not used [-Wunused-private-field] FT_Face _ftFace; ^ 1 warning generated. SOLINK_MODULE(target) Release/canvas.node SOLINK_MODULE(target) Release/canvas.node: Finished [email protected] node_modules/canvas └── [email protected]