The cairo package was not found in the pkg-config search path. Node js fix canvas issue

I had a problem installing the canvas module in a node. Something seems to be with Cairo. I get this error ...

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 /Users/plimb/Desktop/motion-therapy/node_modules/canvas > node-gyp rebuild Package cairo was not found in the pkg-config search path. Perhaps you should add the directory containing 'cairo.pc' to the PKG_CONFIG_PATH environment variable No package 'cairo' 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 (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:424: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" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /Users/plimb/Desktop/motion-therapy/node_modules/canvas gyp ERR! node -v v0.10.21 gyp ERR! node-gyp -v v0.10.10 gyp ERR! not ok npm ERR! weird error 1 npm ERR! not ok code 0 

I'm not sure what all this means! I would be grateful for any help! For example, as for mkdir cairo pc in the environment variable pkg_config_path?

+82
terminal canvas cairo
Feb 28 '14 at 16:12
source share
8 answers

There was the same problem, and @Epistemex helped me fix it.

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

 sudo apt-get install libcairo2-dev libjpeg-dev libgif-dev 
+107
May 14 '14 at 8:09
source share

I also had a problem with mac so I tried these steps and I got a 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 1, you will need to set the PKG_CONFIG_PATH environment variable so that you can find cairo.pc and fontconfig.pc

 $ 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 0, then everything is fine in the hood.

 $ npm install canvas 
+55
Dec 30 '15 at 12:58
source share

Had the same problem in OS X 10.11.2 when installing the qrcode package.

It is solved by installing these:

 brew install cairo brew install pkg-config xcode-select --install 
+31
Jan 15 '16 at 23:21
source share

If someone still has this problem and found this page, for CentOS 6.6 the following works:

 sudo yum install cairo cairo-devel 

Basically the solution - you need to install the development package, as well as the regular package (the best answer here does the same thing - except for Ubuntu - each distribution may be different).

+12
Apr 15 '15 at 16:46
source share

I just needed to install pkg-config on OSX 10.10.4

brew install pkg-config

+1
Sep 18 '15 at 6:02
source share

When I ran into this problem, the problem was that the version of pkg-config in my path was the version provided by chefdk and not the version installed for homebrew.

 $ which pkg-config /usr/local/bin/pkg-config $ eval "$(chef shell-init bash)" $ which pkg-config /opt/chefdk/embedded/bin/pkg-config 

The solution was to remove the eval "$(chef shell-init bash)" entry eval "$(chef shell-init bash)" from my bash profile eval "$(chef shell-init bash)" .

A more detailed discussion of the problem of creating a chefdk path on Github https://github.com/chef/chef-dk/issues/313

+1
Feb 01 '18 at 0:07
source share

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 
+1
Oct 10 '18 at 20:15
source share

I followed the instructions of @Piyush. But I needed an extra step to make it work. I am 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 
0
May 22 '19 at 5:46
source share



All Articles