Gulp problems with cario install command not found when trying to install canvas

I am new to working on the command line. I have a project that I am setting up with gulp, and gulp has installed and compiled sass files. However, I cannot install canvas with:

$ npm install canvas 

I need to set the canvas due to the dependencies that the css sprite must execute. I get the following error. I installed cairo, quartz and homebrew. I examined other tickets and tried to run export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig and install again. I was not lucky and I have no idea what else to do in trying to troubleshoot.

Here is the mistake ...

 npm http GET https://registry.npmjs.org/canvas npm http 304 https://registry.npmjs.org/canvas npm http GET https://registry.npmjs.org/nan npm http 304 https://registry.npmjs.org/nan canvas@1.1.3 install /usr/local/lib/node_modules/canvas node-gyp rebuild ./util/has_cairo_freetype.sh: line 4: pkg-config: command not found gyp: Call to './util/has_cairo_freetype.sh' returned exit status 0. gyp ERR! configure error gyp ERR! stack Error: `gyp` failed with exit code: 1 gyp ERR! stack at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:337:16) gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17) gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:797:12) gyp ERR! System Darwin 13.1.0 gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /usr/local/lib/node_modules/canvas gyp ERR! node -v v0.10.26 gyp ERR! node-gyp -v v0.12.2 gyp ERR! not ok npm ERR! canvas@1.1.3 install: `node-gyp rebuild` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the canvas@1.1.3 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.1.0 npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "canvas" npm ERR! cwd /Users/kylebebeau/websites/ls/code/templates/ls3 npm ERR! node -v v0.10.26 npm ERR! npm -v 1.4.3 npm ERR! code ELIFECYCLE npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /Users/kylebebeau/websites/ls/code/templates/ls3/npm-debug.log npm ERR! not ok code 0 

Any help or guidance is appreciated.

+3
source share
1 answer

I also had this problem. I also used brew to install cairo and quartz. I followed the instructions here and it was this step that fixed my problem.

export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig

Make sure you add this to your .bashrc or .zshrc if you want it to persist in all sessions. I deleted my node_modules directory after successful compilation and tried npm install again in a new terminal session and I had to re-export this PKG_CONFIG_PATH so that it could compile again.

Here is my conclusion shortened for demonstration.

 $ npm install > node-gyp rebuild 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 ... $ export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig $ npm install $ canvas@1.1.3 install $HOME/projects/canvas/node_modules/canvas $ node-gyp rebuild ... Successful Compile 

npm start worked without errors at this point

I hope this helps someone else who comes across this.

+2
source

Source: https://habr.com/ru/post/1493965/


All Articles