简体   繁体   中英

Puppeteer on Raspberry pi zero w

I want to run a node js script with puppeteer on Raspberry pi zero w, but I'm getting this error:

(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

Can you tell me, what can I do with it?

Puppeteer uses the bundled Chromium by default. The error says it was not able to launch it.

You should manually install the Chromium and make Puppeteer use that version instead. Assuming that you have installed it in /usr/bin/chromium , something like this will do the job:

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

Here is the basic code for getting Chrome headless and Puppeteer working on the Raspberry Pi, with a fresh install of Raspbian Stretch Lite.

sudo apt install chromium-browser chromium-codecs-ffmpeg
sudo apt install npm
npm install puppeteer-core@v1.11.0

in node.js

const puppeteer = require('puppeteer-core');

const browser = await puppeteer.launch({executablePath: '/usr/bin/chromium-browser'});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM