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.
source share