Error with Pupperteer

Anonymous
TRIAL

2 years ago

I have an application built with Nuxt 3 and I want to export PDF files. For this I have installed Puppetter, locally it works fine, but when I deploy to railway and make a request to the API it returns the following error:
Chrome could not be found (ver. 119.0.6045.105). This can happen if: either 1. you have not performed an installation before running the script (e.g. npm install) or 2. your cache path is configured incorrectly (which is: /root/.cache/puppeteer).For (2), see our guide on configuring puppeteer at https://pptr.dev/guides/configuration.

Do I need to do any extra configuration?

5 Replies

2 years ago

Make sure your dependency is puppeteer and not puppeteer-core as puppeteer-core will not automatically install Chrome


Anonymous
TRIAL

2 years ago

Yes, my dependency is "puppeteer": "^21.3.6"

I launch with this snipped.
const browser = await launch({ headless: 'new' })

I also try with:
args: ['--no-sandbox', '--disable-setuid-sandbox'],
ignoreDefaultArgs: ['--disable-extensions'],

but doesn't works


Anonymous
TRIAL

2 years ago

{ headless: true } also does not work


lahammam
PRO

a year ago

I'm facing the some issue while using html-pdf-node. It works properly on my local machine, but I encounter the following error when running it on Railway:
ERROR [ExceptionsHandler] Failed to launch the browser process!
error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory.
I attempted to install libnss3 in the Docker environment, but unfortunately, the same error persists.


a year ago

I would highly recommend using Browserless, using it means you don't have to install Chrome and all of its needed dependencies into your container or deal with any of the issues involved in that, and this will significantly speed up both the build and the publishing stage.

You can use it with puppeteer to generate PDFs.

puppeteer's PDF documentation here - https://pptr.dev/api/puppeteer.page.pdf

Browserless template here - https://railway.app/template/browserless

Example using puppeteer with browserless here - https://github.com/brody192/puppeteer-example