1

我正在努力在 CentOS 7 上安装node-canvas 。

按照建议,我按照安装说明执行了以下命令:

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

之后我尝试安装画布

npm install canvas

我还尝试了其他选项,例如 -g 和 --save,但总是遇到相同的错误:

> canvas@1.6.7 install /root/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_lib.sh freetype' returned exit status 0 while 
in binding.gggyp: Call to './util/has_lib.sh freetype' returned exit 
status 0 while in binding.ggyp: Call to './util/has_lib.sh freetype' 
returned exit status 0 while in binding.gyp. 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 
(/opt/bitnami/nodejs/lib/node_modules/npm/node_modules/node-
gyp/lib/configure.js:336:16)
gyp ERR! stack     at emitTwo (events.js:125:13)
gyp ERR! stack     at ChildProcess.emit (events.js:213:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit 
(internal/child_process.js:200:12)
gyp ERR! System Linux 3.10.0-693.2.2.el7.x86_64
gyp ERR! command "/opt/bitnami/nodejs/bin/.node.bin" 
"/opt/bitnami/nodejs/lib/node_modules/npm/node_modules/node-
gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /root/node_modules/canvas
gyp ERR! node -v v8.5.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
npm WARN root@1.0.0 No description
npm WARN root@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! canvas@1.6.7 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the canvas@1.6.7 install script.
npm ERR! This is probably not a problem with npm. There is likely 
additional logging output above.

我知道,这个问题已经在这里发布了

所以我尝试将 cairo.pc 添加到 pkg-config 搜索路径

[root@localhost ~]# find / -name cairo.pc
 /usr/lib64/pkgconfig/cairo.pc
[root@localhost ~]# export PKG_CONFIG_PATH=/usr/lib64/pkgconfig
[root@localhost ~]# echo $PKG_CONFIG_PATH
 /usr/lib64/pkgconfig

但我仍然遇到同样的错误

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

仍然返回 1。

4

0 回答 0