MAC上安装node-canvas

安装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




阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zyx4843/article/details/46809151
文章标签: canvas node.js
个人分类: Nodejs
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭