linux nodejs无法安装canvas模块

报错如下:

shell 复制代码
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

相关推荐
Karoku06616 分钟前
【CI/CD】CI/CD环境搭建流程和持续集成环境配置
运维·ci/cd·docker·容器·kubernetes·prometheus
Nerd Nirvana2 小时前
软考—系统架构设计(案例 | 论文)
linux·系统架构·软件工程·软考·计算机基础
勤奋的凯尔森同学3 小时前
webmin配置终端显示样式,模仿UbuntuDesktop终端
linux·运维·服务器·ubuntu·webmin
丁卯4044 小时前
Go语言中使用viper绑定结构体和yaml文件信息时,标签的使用
服务器·后端·golang
chengooooooo4 小时前
苍穹外卖day8 地址上传 用户下单 订单支付
java·服务器·数据库
人间打气筒(Ada)6 小时前
MySQL主从架构
服务器·数据库·mysql
落笔画忧愁e7 小时前
FastGPT快速将消息发送至飞书
服务器·数据库·飞书
小冷爱学习!7 小时前
华为动态路由-OSPF-完全末梢区域
服务器·网络·华为
技术小齐7 小时前
网络运维学习笔记 016网工初级(HCIA-Datacom与CCNA-EI)PPP点对点协议和PPPoE以太网上的点对点协议(此处只讲华为)
运维·网络·学习
ITPUB-微风7 小时前
Service Mesh在爱奇艺的落地实践:架构、运维与扩展
运维·架构·service_mesh