Reputation: 505
I'm using Puppeteer on Heroku and I receive the following error:
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
Upvotes: 7
Views: 9449
Reputation: 61
Adding this github repo to my heroku buildpack worked for me
https://github.com/jontewks/puppeteer-heroku-buildpack
Upvotes: 2
Reputation: 11
You cant run Puppeteer on Heroku with headless: false because it doesn't have GUI to show.
You need to use headless: true that's because it's running on a Linux without GUI
If you have another errors, you may want to read the official Puppeteer troubleshooting guide: Running Puppeteer on Heroku.
Upvotes: 1
Reputation: 437
Declare browser as:
const browser = await puppeteer.launch({
headless: true,
args: ['--no-sandbox','--disable-setuid-sandbox']
})
Install heroku buildpack
puppeteer heroku buildpack
Must clear heroku cache
git add .
git commit -m "some text"
git push heroku master
Upvotes: 21
Reputation: 139
May be this could help (copied from Puppeteer official website)
Running Puppeteer on Heroku (https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#running-puppeteer-on-heroku)
Running Puppeteer on Heroku requires some additional dependencies that aren't included on the Linux box that Heroku spins up for you. To add the dependencies on deploy, add the Puppeteer Heroku buildpack to the list of buildpacks for your app under Settings > Buildpacks.
The url for the buildpack is https://github.com/jontewks/puppeteer-heroku-buildpack
Ensure that you're using '--no-sandbox' mode when launching Puppeteer. This can be done by passing it as an argument to your .launch() call: puppeteer.launch({ args: ['--no-sandbox'] });.
When you click add buildpack, simply paste that url into the input, and click save. On the next deploy, your app will also install the dependencies that Puppeteer needs to run.
If you need to render Chinese, Japanese, or Korean characters you may need to use a buildpack with additional font files like https://github.com/CoffeeAndCode/puppeteer-heroku-buildpack
There's also another simple guide from @timleland that includes a sample project: https://timleland.com/headless-chrome-on-heroku/.
Upvotes: 5