centos8安装puppeteer
背景
我计划使用puppeteer爬点html数据,结果windows11上没问题 但在我的服务器centos8上确报错。
[root@104 auto-task]# npm run start
> auto-task@1.0.0 start
> node src/main.js
启动成功:http://localhost:3000
Error: Failed to launch the browser process!
/root/.cache/puppeteer/chrome/linux-114.0.5735.133/chrome-linux64/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory
TROUBLESHOOTING: https://pptr.dev/troubleshooting
at Interface.onClose (file:///home/auto-task/node_modules/@puppeteer/browsers/lib/esm/launch.js:250:24)
at Interface.emit (node:events:525:35)
at Interface.close (node:internal/readline/interface:533:10)
at Socket.onend (node:internal/readline/interface:259:10)
at Socket.emit (node:events:525:35)
at endReadableNT (node:internal/streams/readable:1359:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
原因分析
网上查找资料得知,本来就是不可能能一凡风顺,官方给出了要想成功使用的必备依赖包。
安装必备依赖
yum install -y pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc
可能出现的问题
无法安装依赖ipa-gothic-fonts
但是我执行以上的安装这些依赖包命令,结果却报错,导致安装依赖失败。
如果你没有下边这个报错,请忽略此环节。
Failed to set locale, defaulting to C
Last metadata expiration check: 0:39:16 ago on Sun Jul 16 01:42:31 2023.
No match for argument: ipa-gothic-fonts
Error: Unable to find a match
还好英语我的英语略懂,根据提示可得知 依赖包 ipa-gothic-fonts找不到。 推测作者可能撤包,也可能是源的问题。
办法简单,通过查找资料获取ipa-gothic-fonts安装包,手动安装即可。
curl -O https://rpmfind.net/linux/fedora/linux/development/rawhide/Everything/x86_64/os/Packages/i/ipa-gothic-fonts-003.03-26.fc38.noarch.rpm
yum install -y ipa-gothic-fonts-003.03-15.el8.noarch.rpm
然后再通过命令安装剩余的依赖即可
yum install -y pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc
升级nss依赖
根据官方要求 升级nss依赖
yum update nss -y
可能出现的问题
执行以上我这里报错 提示我服务器上压根就没有nss这个包,
[root@104 ~]# yum update nss -y
Last metadata expiration check: 0:17:42 ago on Sun 16 Jul 2023 12:49:13 AM EDT.
Package nss available, but not installed.
No match for argument: nss
Error: No packages marked for upgrade.
那更好办了,直接全新安装即可
yum install nss -y
还是不能运行?
是的,按照官方要求,安装了上诉的这些必备依赖项之后,还是提示报错。这是怎么回事?
[root@104 auto-task]# npm run start
> auto-task@1.0.0 start
> nodesrc/main.js
启动成功:http://localhost:3000
Error: Failed to launch the browser process!
/root/.cache/puppeteer/chrome/linux-114.0.5735.133/chrome-linux64/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory
TROUBLESHOOTING: https://pptr.dev/troubleshooting
at Interface.onClose (file:///home/auto-task/node_modules/@puppeteer/browsers/lib/esm/launch.js:250:24)
at Interface.emit (node:events:525:35)
at Interface.close (node:internal/readline/interface:533:10)
at Socket.onend (node:internal/readline/interface:259:10)
at Socket.emit (node:events:525:35)
at endReadableNT (node:internal/streams/readable:1359:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
根据分析 应该(chrome运行时的)依赖仍然缺少。我们去验证下
cd /root/.cache/puppeteer/chrome/linux-114.0.5735.133/chrome-linux64
ldd chrome | grep not
下边可以看到缺少哪些依赖 导致chrome启动失败
[root@104 chrome-linux64]# ldd chrome | grep not
libdrm.so.2 => not found
libgbm.so.1 => not found
那我们安装这些缺少的依赖即可
yum install libdrm libgbm libxshmfence -y
最后再次执行上边的命令看一次是否缺少依赖,如果不出意外,全部依赖安装成功!
结语
至此,再试试你的程序 是不是可以正常运行puppeteer了!
其他问题
装完后 打开shell 可能会提示如下错误,但不影响使用
manpath: can't set the locale; make sure $LC_* and $LANG are correct
这是语言和区域的兼容问题,如果觉得影响美观,可以执行如下代码即可。
echo "LC_ALL=en_US.UTF-8" >> /etc/environment
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
# locale-gen en_US.UTF-8
centos8安装puppeteer的更多相关文章
- centos8 安装vmware需要的内核头文件 kernel-headers.
centos8 安装vmware需要的内核头文件 kernel-headers. uname -r (查看内核版本) rpm -qa kernel-headers (查看kernel-headers版 ...
- Centos8安装Docker提示:package docker-ce-3:19.03.8-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed
Centos8安装Docker提示:package docker-ce-3:19.03.8-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but ...
- centos8安装fastdfs6.06集群方式三之:storage的安装/配置/运行
一,查看本地centos的版本 [root@localhost lib]# cat /etc/redhat-release CentOS Linux release 8.1.1911 (Core) 说 ...
- centos8安装fastdfs6.06集群方式二之:tracker的安装/配置/运行
一,查看本地centos的版本 [root@localhost lib]# cat /etc/redhat-release CentOS Linux release 8.1.1911 (Core) 说 ...
- centos8安装fastdfs6.06集群方式一之:软件下载与安装
一,查看本地centos的版本 [root@localhost lib]# cat /etc/redhat-release CentOS Linux release 8.1.1911 (Core) 说 ...
- CentOS8 安装MySQL5.7
CentOS_8 安装MySQL5.7 1.在安装之前,如果你的系统曾经安装过Mariadb,请先卸载:yum remove mariadb*2.安装依赖 yum install -y epel-re ...
- CentOS8安装VirtualBox,并创建CentOS虚拟机
安装VirtualBox 执行以下命令并启用VirtualBox和EPEL包仓库 [root@localhost~] dnf config-manager --add-repo=https://dow ...
- 在MacOS安装puppeteer
安装node:升级:npm i npm 安装yarn:需要注意先把yarn的流程跑完,特别是package.json 安装puppeteer:yarn add puppeteer 安装完成以后需要重启 ...
- CentOS8安装Geant4笔记(三):Geant4介绍、编译、安装支持Qt5界面并运行exampleB1例程显示Qt界面
前言 上一篇,安装了Qt5环境. 本篇在服务器CentOs8.2上安装geant4软件,geant4使用Qt5来显示. GEANT4 介绍 Geant4 是一个用于模拟粒子穿过物质的工具 ...
- Centos8安装nvidia驱动
Centos8安装nvidia驱动 1. 查看显卡型号 lspci | grep-i nvidia 或者 lspci -vnn | grep VGA 2. 前往nvidia官网下载对应驱动 NVIDI ...
随机推荐
- 基于STM32F4+FREERTOS进行结构体变量的传递
原始参考链接如下↓ Freertos 接收消息队列数据不对,是姿势不正确吗 - STM32H7 - 硬汉嵌入式论坛 - Powered by Discuz! https://www.armbbs.cn ...
- vue-element-admin整合服务端代理api
1. 找到vue.config.js,在devServer中编辑如下 devServer: { port: port, open: true, overlay: { warnings: false, ...
- python批量下载网易云音乐文件到本地
现在听歌大多数只支持在线听,下载要钱,没网络就白搭了.好吧,用技术手段解决免费.下载.批量等一些列问题 整个脚本的逻辑和流程是,把歌曲地址都存在一个txt中,然后循环每次取一条链接,分析链接对应歌曲的 ...
- 极客时间上新 .NET + AI 体系课
课程特色 1️⃣ 全网首个.NET+AI体系化课程(没有之一!) 2️⃣ Semantic Kernel + Kernel Memory 核心知识全覆盖 3️⃣ 每课时基于Polyglot Noteb ...
- Fiddler的安装和使用教程(详细)
一.安装 1.fiddler工具下载网址:http://www.telerik.com/download/fiddler. 2.运行 FiddlerSetup.exe一键完成安装. 3.安装成功后点击 ...
- python-docx设置标题颜色
from docx import Document from docx.enum.text import WD_PARAGRAPH_ALIGNMENT from docx.shared import ...
- 第二章 Spring Boot 整合 Kafka消息队列 生产者
系列文章目录 第一章 Kafka 配置部署及SASL_PLAINTEXT安全认证 第二章 Spring Boot 整合 Kafka消息队列 生产者 第三章 Spring Boot 整合 Kaf ...
- 【HUST】网安|计算机网络安全实验|实验二 DNS协议漏洞利用实验
写在最前: 这是我个人的实验记录,实现方式有很多种,多台虚拟机更容易做netwox. 认真整理和记录了一下容易出问题的地方. 代码仓库开了. 文章目录 涉及代码的仓库地址 计算机网络安全实验二 DNS ...
- Linux系列:如何用perf跟踪.NET程序的mmap泄露
一:背景 1. 讲故事 如何跟踪.NET程序的mmap泄露,这个问题困扰了我差不多一年的时间,即使在官方的github库中也找不到切实可行的方案,更多海外大佬只是推荐valgrind这款工具,但这款工 ...
- ESP32 MQTT对接巴法云平台
ESP32 MQTT对接巴法云平台 MQTT(Message Queuing Telemetry Transport)是一种轻量级的 发布/订阅(Publish/Subscribe) 消息传输协议,专 ...