报错如下:
Failed to execute '/www/server/nodejs/xxxxx/bin/node /www/server/nodejs/xxxxx/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --update-binary --module=/www/wwwroot/nodejs/xxxxx/node_modules/canvas/build/Release/canvas.node --module_name=canvas --module_path=/www/wwwroot/nodejs/xxxxx/node_modules/canvas/build/Release --napi_version=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v83' (1)
npm WARN epaper No description
npm WARN epaper No repository field.
npm WARN epaper No license field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! canvas@2.11.2 install: node-pre-gyp install --fallback-to-build --update-binary
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the canvas@2.11.2 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
原因是缺少系统包,解决办法如下:
centos系统
更新系统
sudo yum update
安装编译工具和依赖项:Canvas 模块需要一些编译工具和依赖项。运行以下命令安装它们:
sudo yum install gcc-c++ cairo-devel pango-devel libjpeg-devel giflib-devel
安装canvas模块
npm install canvas
Debian及Ubuntu
更新系统
sudo apt-get update
sudo apt upgrade
安装编译工具和依赖项:Canvas 模块需要一些编译工具和依赖项。运行以下命令安装它们:
sudo apt install build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev
安装canvas模块
npm install canvas