node.js - Raspberry pi 零 w 上的 Puppeteer
问题描述
我想在 Raspberry pi 零 w 上使用 puppeteer 运行节点 js 脚本,但出现此错误:
(node:5699) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!
/SteamCheaper/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: 1: /SteamCheaper/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: �: not found
/SteamCheaper/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: 1: /SteamCheaper/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: ELF: not found
/SteamCheaper/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: 2: /SteamCheaper/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: p#: not found
/SteamCheaper/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: 3: /SteamCheaper/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: p#: not found
/SteamCheaper/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: 4: /SteamCheaper/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: @l�: not found
/SteamCheaper/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: 5: /SteamCheaper/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: pX: not found
/SteamCheaper/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: 6: /SteamCheaper/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: pX: not found
/SteamCheaper/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: 7: /SteamCheaper/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: Syntax error: "(" unexpected
/SteamCheaper/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: 4: /SteamCheaper/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: ��q: not found
你能告诉我,我能用它做什么吗?
解决方案
Puppeteer 默认使用捆绑的 Chromium。该错误表明它无法启动它。
您应该手动安装 Chromium 并让 Puppeteer 使用该版本。假设您已将其安装在 中/usr/bin/chromium
,这样的事情就可以完成:
const browser = await puppeteer.launch({
product: "chrome", executablePath: "/usr/bin/chromium",
})
推荐阅读
- azure - az tag update 错误:(MissingSubscription)请求没有订阅或有效的租户级资源提供程序
- django - Django 创建电子邮件更改确认电子邮件
- java - 获取从 pom.xml 到 List 的依赖关系
- ros - 在 IMU 集成后,robot_localization 包中的线性速度,并且只有一个传感器 (IMU) 作为传感器输入
- javascript - 如何获得人类格式的持续时间(1小时4分钟)
- assembly - Pep8 数字分解
- laravel - 试图在 Laravel 8 中获取非对象的属性“名称”
- vue.js - V-model 正在更新未引用的状态数据
- docker - 在容器化应用程序中,Docker Engine 是否位于应用程序和操作系统之间?
- android - Android Out Of Memory Error Crash - 墓碑解读