kaushik balamurali
kaushik balamurali

Reputation: 11

Error: Could not find Chrome (ver. 124.0.6367.91)

I am making a desktop application using electron and giving the output using puppeteer in PDF.

My Puppeteer works as expected if I run it using npm and it also runs fine when I package it using electron-forge package in my machine. However, it gives me this error on a different machine:

> Error: Could not find Chrome (ver. 124.0.6367.91). This can occur if either
 1. you did not perform an installation before running the script (e.g. `npx puppeteer browsers install chrome`) or
 2. your cache path is incorrectly configured (which is: %USERPROFILE%\.cache\puppeteer).
For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.
    at ChromeLauncher.resolveExecutablePath (<user desktop directory>\sahacharya_fii_billgenerator-win32-x64\resources\app.asar\node_modules\puppeteer-core\lib\cjs\puppeteer\node\ProductLauncher.js:295:27)
    at ChromeLauncher.executablePath (<desktop directory>\sahacharya_fii_billgenerator-win32-x64\resources\app.asar\node_modules\puppeteer-core\lib\cjs\puppeteer\node\ChromeLauncher.js:209:25)
    at ChromeLauncher.computeLaunchArguments (<desktop directory>\sahacharya_fii_billgenerator-win32-x64\resources\app.asar\node_modules\puppeteer-core\lib\cjs\puppeteer\node\ChromeLauncher.js:89:37)
    at async ChromeLauncher.launch (<desktop directory>\sahacharya_fii_billgenerator-win32-x64\resources\app.asar\node_modules\puppeteer-core\lib\cjs\puppeteer\node\ProductLauncher.js:70:28)
    at async generatePDF (<desktop directory>\sahacharya_fii_billgenerator-win32-x64\resources\app.asar\main.js:560:25)
    at async <desktop directory>\sahacharya_fii_billgenerator-win32-x64\resources\app.asar\main.js:508:25
    at async WebContents.<anonymous> (node:electron/js2c/browser_init:2:82793) 

When I copy the packaged application to another machine or I make a distributable file and install it using electron-forge make .

I have tried setting executable chrome path like this:

const browser = await puppeteer.launch({ executablePath: myPath });

and also tried making .local-chromium file in Puppeteer. It all works fine when I package it in my machine and run it in my machine but it again gives me the above error when i try it on any other machine

I tried setting executable path but it gave error path should be in string format even though it was in a string format in while packaging it. I tried specifying Chromium version in the forge.config.js file and also tried creating .local-chromium folder in puppeteer node_modules folder and copying Chrome in it.

Upvotes: 1

Views: 837

Answers (1)

Michael Eliot
Michael Eliot

Reputation: 1186

I was able to get this working using the puppeteer docker container, and this youtube video

Dockerfile

FROM ghcr.io/puppeteer/puppeteer:latest

ENV PUPPETEER_SKIP_DOWNLOAD=true \
    PUPPETEER_EXECUTABLE_PATH=/usr/bin/google-chrome-stable

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm ci

COPY . .

USER root

CMD [ "npm", "run", "start" ]

Upvotes: 0

Related Questions