简体   繁体   English

Package 在 pkg-config 搜索路径中找不到 cairo。 Node js 安装 canvas 问题

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

I am having a problem installing installing the canvas module in node..It seems to be something with cairo I am getting this error...我在节点中安装 canvas 模块时遇到问题。这似乎与开罗有关,我收到此错误...

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 it all means?我不确定这一切意味着什么? Would appreciate any help!For example how to a mkdir cairo pc in the pkg_config_path environment variable?将不胜感激任何帮助!例如,如何在 pkg_config_path 环境变量中使用 mkdir cairo pc?

Had the same problem and @Epistemex's link helped me troubleshoot it.遇到了同样的问题, @Epistemex 的链接帮助我解决了问题。

... You need to install libcairo2-dev , libjpeg-dev and libgif-dev packages ... ...您需要安装libcairo2-devlibjpeg-devlibgif-dev包...

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 上也遇到了同样的问题,所以我尝试了这些步骤并得到了解决方案

Mac OSX Version >=10.7.5 node -v = v0.8.12 Mac OSX 版本 >=10.7.5 节点 -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如果它返回 1,您将需要设置 PKG_CONFIG_PATH 环境变量,以便可以找到 cairo.pc 和 fontconfig.pc

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

Running pkg-config again ...再次运行 pkg-config ...

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

$ echo $?

If it returns a 0 then all is well in the hood.如果它返回 0,那么一切都很好。

$ npm install canvas

Had the same problem on OS X 10.11.2 while installing qrcode package.在 OS X 10.11.2 上安装qrcode包时遇到同样的问题。

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:如果有人仍然遇到此问题并找到此页面,则以下内容适用于 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).基本上,解决方案是您需要安装开发包以及常规包(这里的最佳答案做同样的事情 - 除了 Ubuntu - 每个发行版都可能不同)。

I followed the steps given by @Piyush.我按照@Piyush 给出的步骤进行了操作。 But I needed an extra step to make it work.但我需要一个额外的步骤来使它工作。 I'm using OS X 10.14.5我使用的是 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

Try this on mac:在 Mac 上试试这个:

brew install pkg-config cairo pango libpng jpeg giflib

The accepted answer is just fine if you use apt-get.如果您使用 apt-get,接受的答案就很好。 For YUM/DNF users (Fedora, CentOS, other RHEL-like systems), use the following对于 YUM/DNF 用户(Fedora、CentOS、其他类似 RHEL 的系统),请使用以下命令

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

When I ran into this problem the issue was that the version of pkg-config on my path was the version supplied by chefdk instead of the homebrew installed version.当我遇到这个问题时,问题是我路径上的pkg-config版本是由 Chefdk 提供的版本,而不是自制软件安装的版本。

$ 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 from my bash profile.解决方案是从我的 bash 配置文件中删除eval "$(chef shell-init bash)"条目。

More discussion of the issue in chefdk's path generation on Github https://github.com/chef/chef-dk/issues/313在 Github https://github.com/chef/chef-dk/issues/313上进一步讨论了 Chefdk 路径生成中的问题

我只需要在 OSX 10.10.4 上安装 pkg-config

brew install pkg-config

For Ubuntu, these're the commands.对于 Ubuntu,这些是命令。 Also, here's the reference .另外,这里是参考

$ sudo apt-get update 
$ sudo apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM