【问题标题】:Puppeteer on Raspberry pi zero wRaspberry pi 零 w 上的 Puppeteer
【发布时间】:2020-05-24 12:38:04
【问题描述】:

我想在 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

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

【问题讨论】:

    标签: node.js linux npm raspberry-pi puppeteer


    【解决方案1】:

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

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

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

    【讨论】:

    • 应该是 executablePath: '/usr/bin/chromium-browser'product: 'chrome' 是关键
    【解决方案2】:

    这是让 Chrome 无头和 Puppeteer 在 Raspberry Pi 上工作的基本代码,以及全新安装的 Raspbian Stretch Lite。

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

    在 node.js 中

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

    【讨论】:

      猜你喜欢
      • 2021-10-20
      • 1970-01-01
      • 1970-01-01
      • 2022-09-25
      • 2021-10-05
      • 1970-01-01
      • 1970-01-01
      • 2022-11-12
      • 1970-01-01
      相关资源
      最近更新 更多