Deploying puppeteer automation script to heroku with browser launch issues

I’m having trouble deploying my Node.js application to Heroku that uses puppeteer for browser automation. Everything works fine locally, but when I push to Heroku, the browser fails to start and throws an error about missing shared libraries.

The error message shows:

Error: Failed to launch the browser process!
chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory

I’ve tried different approaches but can’t seem to get the Chrome browser to launch properly on the Heroku dyno. Has anyone successfully deployed puppeteer applications to Heroku before? What configuration changes or buildpacks are needed to make this work?

Had the same issue with my puppeteer app on Heroku. Heroku doesn’t include Chrome dependencies by default, so you need to add the puppeteer buildpack first: heroku buildpacks:add jontewks/puppeteer (make sure it’s before the Node.js buildpack). Also update your launch options to {args: ['--no-sandbox', '--disable-setuid-sandbox']}. This installs Chrome with all the shared libraries you need, including libnss3.so, which should fix your errors.

Hit this same issue six months back with my web scraping service. The buildpack fix works, but go with heroku/google-chrome instead - it’s way better maintained than jontewks. Don’t forget to set the executable path: puppeteer.launch({executablePath: process.env.GOOGLE_CHROME_BIN}). Heads up - Heroku’s free tier can’t handle Chrome’s memory needs. You’ll need the basic plan minimum. Chrome gets flaky on limited resources, so add solid error handling and timeouts.

yeah, classic heroku problem. beyond the buildpack fix, switch to puppeteer.launch({headless: 'new'}) instead of headless: true. heroku dynos don’t have displays, so headless is required. also double-check your puppeteer version - newer ones often need different chrome flags on heroku’s ubuntu stack.