Error with Pupperteer
victj99
HOBBYOP

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?

6 Replies

2 years ago

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


victj99
HOBBYOP

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


victj99
HOBBYOP

2 years ago

{ headless: true } also does not work


lahammam
PRO

2 years 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.


2 years 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


gamerkingfaiz
HOBBY

3 months ago

My use case doesn't allow me to use Browserless anymore, so I wanted to get standard puppeteer working on Railway and this is the setup I needed for it to work successfully.

"puppeteer": "^24.31.0"
    const browser = await puppeteer.launch({
      headless: true,
      args: [
        "--no-sandbox",
        "--disable-setuid-sandbox",
        "--disable-dev-shm-usage",
        // "--single-process",
        "--no-zygote",
      ],
    });

You may be able to get away with leaving out some of the args, but this works for me, so I thought I'd share!


Loading...