I had this issue as well. I had also used brew to install cairo and quartz. I followed these instructions here and most specifically this step fixed my issue.
export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig
Make sure that you add this to your .bashrc
or .zshrc
if you want it to persist across sessions. I deleted my node_modules
directory after successfully compiling and tried to npm install
again in a new terminal session and I had to re-export that PKG_CONFIG_PATH to allow it to compile properly again.
Here is my output abbreviated to demonstrate.
$ 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 anyone else that runs into this.