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

相关推荐
深紫色的三北六号21 小时前
Linux 服务器磁盘扩容与目录迁移:rsync + bind mount 实现服务无感迁移(无需修改配置)
linux·扩容·服务迁移
SudosuBash1 天前
[CS:APP 3e] 关于对 第 12 章 读/写者的一点思考和题解 (作业 12.19,12.20,12.21)
linux·并发·操作系统(os)
哈基咪怎么可能是AI1 天前
为什么我就想要「线性历史 + Signed Commits」GitHub 却把我当猴耍 🤬🎙️
linux·github
十日十行2 天前
Linux和window共享文件夹
linux
Sinclair2 天前
简单几步,安卓手机秒变服务器,安装 CMS 程序
android·服务器
木心月转码ing2 天前
WSL+Cpp开发环境配置
linux
Rockbean3 天前
用40行代码搭建自己的无服务器OCR
服务器·python·deepseek
蝎子莱莱爱打怪3 天前
Centos7中一键安装K8s集群以及Rancher安装记录
运维·后端·kubernetes
茶杯梦轩3 天前
CompletableFuture 在 项目实战 中 创建异步任务 的核心优势及使用场景
服务器·后端·面试
崔小汤呀3 天前
最全的docker安装笔记,包含CentOS和Ubuntu
linux·后端