关闭

MAC上安装node-canvas

标签: canvasnode.js
519人阅读 评论(0) 收藏 举报
分类:

安装Node.js的canvas库时发现canvas依赖cairo包:


$ npm install canvas
...
> node-gyp rebuild
...
No package 'cairo' found


可以通过brew安装,但是安装时发现cairo依赖于X11:

$ brew install cairo
cairo: Unsatisfied dependency: XQuartz 
Homebrew does not package XQuartz. Installers may be found at:

x11可以从官网https://xquartz.macosforge.org下载,安装即可。

安装完要设置环境变量不然会报如下错误:

$ npm install canvas
...
Package xcb-shm was not found in the pkg-config search path.
Perhaps you should add the directory containing `xcb-shm.pc'
to the PKG_CONFIG_PATH environment variable
Package 'xcb-shm', required by 'cairo', not found
环境变量的设置:

$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig
然后依次安装就可以了:

$ brew install cairo

$ npm install canvas




0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:20833次
    • 积分:534
    • 等级:
    • 排名:千里之外
    • 原创:32篇
    • 转载:8篇
    • 译文:0篇
    • 评论:7条
    文章分类
    最新评论