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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22100213/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 16:56:26  来源:igfitidea点击:

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

node.jscanvasterminalcairo

提问by plimbs

I am having a problem installing installing the canvas module in node..It seems to be something with cairo I am getting 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

> [email protected] 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?

回答by HenryHey

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

遇到了同样的问题,@Epistemex 的链接帮助我解决了问题。

... You need to install libcairo2-dev, libjpeg-devand libgif-devpackages ...

...你需要安装libcairo2-devlibjpeg-devlibgif-dev包...

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

回答by Piyush Dholariya

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

回答by Alexander Danilov

Had the same problem on OS X 10.11.2 while installing qrcodepackage.

安装qrcode软件包时在 OS X 10.11.2 上遇到了同样的问题。

Solved by installing these ones:

通过安装这些解决方案:

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

回答by Ryan M

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 - 每个发行版都可能不同)。

回答by Yasith Prabuddhaka

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

我遵循了@Piyush 给出的步骤。但我需要一个额外的步骤来使它工作。我使用的是 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

回答by Clay

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

如果您使用 apt-get,接受的答案就很好。对于 YUM/DNF 用户(Fedora、CentOS、其他类似 RHEL 的系统),请使用以下命令

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

回答by Brian Skarda

When I ran into this problem the issue was that the version of pkg-configon my path was the version supplied by chefdk instead of the homebrew installed version.

当我遇到这个问题时,问题是pkg-config我路径上的版本是cheftk提供的版本,而不是自制软件安装的版本。

$ 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.

解决方案是eval "$(chef shell-init bash)"从我的 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 路径生成中的问题

回答by Fush

I just needed to install pkg-config on OSX 10.10.4

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

brew install pkg-config

brew install pkg-config

回答by Shahar Ben Ezra

For Ubuntu, these're the commands. Also, here's the reference.

对于 Ubuntu,这些是命令。另外,这里是参考

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