解决 node-canvas 失败问题 #5501
Aarebecca
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
如果在安装依赖阶段出现
node-canvas
无法安装的问题(通常是由于使用了 ARM 架构的 CPU 导致),请根据下列方法进行排查不使用 pnpm (ref: https://devzilla.io/using-nodejs-14-with-mac-silicon-m1)
一、前置环境检查
安装
nvm
二、执行安装
arch
(应当会返回arm64
)arch -x86_64 zsh
arch
(应当会返回i386
)node 14
node
版本三、尝试安装
使用pnpm
因为
pnpm
要求node
版本大于 14,所以需要安装下列步骤解决一、前置环境检查
开始前,请检查本地环境:
node
: >= 16pnpm
: >= 8二、安装系统依赖 (ref: https://github.com/Automattic/node-canvas/blob/master/Readme.md)
brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman
sudo apt-get install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
sudo yum install gcc-c++ cairo-devel pango-devel libjpeg-turbo-devel giflib-devel
pkgin install cairo pango pkg-config xproto renderproto kbproto xextproto
doas pkg_add cairo pango png jpeg giflib
完成上述操作后,再次尝试安装依赖
三、从源码编译 (ref: https://github.com/Automattic/node-canvas/wiki/Installation%3A-Mac-OS-X)
如果上述步骤仍无法正常安装,请安装下面方法编译
安装 pkg-config
安装 Pixman
安装 Cairo
添加环境变量:
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
再次安装
打开新的终端(或者环境变量生效后),再次执行:
Beta Was this translation helpful? Give feedback.
All reactions