首页 > 解决方案 > Heroku 上的 Puppeteer:无法启动浏览器进程

问题描述

我在 Heroku 上使用 Puppeteer 并收到以下错误:

Failed to launch the browser process! /usr/src/app/node_modules/puppeteer/.local-chromium/linux-756035/chrome-linux/chrome: error while loading shared libraries: libX11-xcb.so.1: cannot open shared object file: No such file or directory TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md

标签: herokupuppeteer

解决方案


  1. Declare browser as:

    const browser = await puppeteer.launch({
                      headless: true,
                      args: ['--no-sandbox','--disable-setuid-sandbox']
                    })
    
  2. Install heroku buildpack puppeteer heroku buildpack

  3. Must clear heroku cache

  4. git add .

  5. git commit -m "some text"

  6. git push heroku master


推荐阅读