Raspberry pi 零 w 上的 Puppeteer

Luk*_*jek 3 linux node.js npm raspberry-pi puppeteer

我想在 Raspberry pi 零 w 上使用 puppeteer 运行节点 js 脚本,\n但我收到此错误:

\n\n
(node:5699) UnhandledPromiseRejectionWarning: Error: Failed to launch the browser process!\n/SteamCheaper/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: 1: /SteamCheaper/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: \xef\xbf\xbd: not found\n/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\n/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\n/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\n/SteamCheaper/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: 4: /SteamCheaper/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: @l\xef\xbf\xbd: not found\n/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\n/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\n/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\n/SteamCheaper/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: 4: /SteamCheaper/node_modules/puppeteer/.local-chromium/linux-722234/chrome-linux/chrome: \xef\xbf\xbd\xef\xbf\xbdq: not found\n
Run Code Online (Sandbox Code Playgroud)\n\n

你能告诉我,我能用它做什么吗?

\n

adv*_*ncd 6

Puppeteer 默认使用捆绑的 Chromium。该错误表明无法启动它。

您应该手动安装 Chromium 并让 Puppeteer 使用该版本。假设您已将其安装在 中/usr/bin/chromium,类似这样的操作就可以完成这项工作:

const browser = await puppeteer.launch({
    product: "chrome", executablePath: "/usr/bin/chromium",
})
Run Code Online (Sandbox Code Playgroud)