Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Package cairo was not found in the pkg-config search path. Node j.s install canvas issue

Had the same problem and @Epistemex's link helped me troubleshoot it.

... You need to install libcairo2-dev, libjpeg-dev and libgif-dev packages ...

sudo apt-get install libcairo2-dev libjpeg-dev libgif-dev

I was also facing same issue on mac so I have tried these steps & I got solution

Mac OSX Version >=10.7.5 node -v = v0.8.12

$ brew install cairo
$ pkg-config --atleast-version=1.12.2 cairo
$ echo $?

If it returns a 1 you will need to set the PKG_CONFIG_PATH environment variable so cairo.pc and fontconfig.pc can be found

$ locate cairo.pc
$ export PKG_CONFIG_PATH=/usr/X11/lib/pkgconfig/

Running pkg-config again ...

$ pkg-config --atleast-version=1.12.2 cairo

$ echo $?

If it returns a 0 then all is well in the hood.

$ npm install canvas

Had the same problem on OS X 10.11.2 while installing qrcode package.

Solved by installing these ones:

brew install cairo
brew install pkg-config
xcode-select --install

If anyone is still having this problem and found this page, the following works for CentOS 6.6:

sudo yum install cairo cairo-devel

Basically the solution is you need to install the development package as well as the regular package (the best answer here does the same thing - except is for Ubuntu - every distro can be different).


I followed the steps given by @Piyush. But I needed an extra step to make it work. I'm using OS X 10.14.5

So this is what I followed.

brew install pkg-config
brew install cairo
pkg-config --atleast-version=1.12.2 cairo
export PKG_CONFIG_PATH=/usr/X11/lib/pkgconfig/
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/usr/local/opt/libffi/lib/pkgconfig"
npm install canvas

The accepted answer is just fine if you use apt-get. For YUM/DNF users (Fedora, CentOS, other RHEL-like systems), use the following

yum install cairo cairo-devel cairomm-devel libjpeg-turbo-devel pango pango-devel pangomm pangomm-devel