Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V4.0.0 get Error: Could not find Chrome (ver. 119.0.6045.105) #218

Open
brickyang opened this issue Nov 17, 2023 · 2 comments
Open

V4.0.0 get Error: Could not find Chrome (ver. 119.0.6045.105) #218

brickyang opened this issue Nov 17, 2023 · 2 comments
Labels
question Further information is requested

Comments

@brickyang
Copy link

brickyang commented Nov 17, 2023

I have been using node-html-to-image for two years and it worked well. Recently I updated all dependencies including this package to v4.0.0 and it doesn't work any more.

Call nodeHtmlToImage() it just thrown an error:

ERROR 1016 nodejs.Error: Unable to launch browser, error message: Could not find Chrome (ver. 119.0.6045.105). This can occur if either
 1. you did not perform an installation before running the script (e.g. `npm install`) or
 2. your cache path is incorrectly configured (which is: /root/.cache/puppeteer).
For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.
 1. you did not perform an installation before running the script (e.g. `npm install`) or
 2. your cache path is incorrectly configured (which is: /root/.cache/puppeteer).
For (2), check out our guide on configuring puppeteer at https://pptr.dev/guides/configuration.
    at Cluster.<anonymous> (/app/node_modules/puppeteer-cluster/dist/Cluster.js:119:23)
    at Generator.throw (<anonymous>)
    at rejected (/app/node_modules/puppeteer-cluster/dist/Cluster.js:6:65)

I googled every error message, read many pages in GIthub and Stack Overflow and tried different version of nodejs and Chrome but got nothing.

Eventually I modified package.json with node-html-to-image ^3, got ERROR 54 nodejs.Error: Unable to launch browser, error message: Could not find expected browser (chrome) locally. Runnpm install to download the correct Chromium revision.

Then I run node node_modules/puppeteer/install.js and enerything is GOOD now.

I have no idea what happened.

------ BACKGROUND ------

I use a Docker container to run my app. The base image is node:20-bullseye-slim and installed Chrome manually. My Dockerfile:

FROM node:20-bullseye-slim

ENV TZ=Asia/Shanghai \
    DEBIAN_FRONTEND=noninteractive \
    LANG=zh_CN.UTF-8

RUN ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime \
    && echo ${TZ} > /etc/timezone \
    && dpkg-reconfigure --frontend ${DEBIAN_FRONTEND} tzdata \
    && apt-get -y update \
    && apt-get install -y wget gnupg2 libxss1 locales \
    && sed -ie 's/# zh_CN.UTF-8 UTF-8/zh_CN.UTF-8 UTF-8/g' /etc/locale.gen \
    && locale-gen \
    && mkdir -p /usr/share/fonts/truetype/SourceHanSerifCN/ \
    && wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
    && echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
    && apt-get -y update && apt-get install -y google-chrome-stable \
    && rm -rf /var/lib/apt/lists/*

COPY SourceHanSerifCN*.otf /usr/share/fonts/truetype/SourceHanSerifCN/

CMD [ "node" ]

My puppeteer args is:

puppeteerArgs: {
        args: [
          '--disable-dev-shm-usage',
          '--enable-sync',
          '--enable-background-networking',
          '--no-sandbox',
          '--disable-setuid-sandbox',
          '--disable-gpu',
          '--renderer',
          '--no-service-autorun',
          '--no-experiments',
          '--no-default-browser-check',
          '--disable-webgl',
          '--disable-threaded-animation',
          '--disable-threaded-scrolling',
          '--disable-in-process-stack-traces',
          '--disable-histogram-customizer',
          '--disable-gl-extensions',
          '--disable-extensions',
          '--disable-composited-antialiasing',
          '--disable-canvas-aa',
          '--disable-3d-apis',
          '--disable-accelerated-2d-canvas',
          '--disable-accelerated-jpeg-decoding',
          '--disable-accelerated-mjpeg-decode',
          '--disable-app-list-dismiss-on-blur',
          '--disable-accelerated-video-decode',
          '--mute-audio',
          '--log-level=3',
          '--disable-infobars',
          '--disable-web-security',
          '--disable-site-isolation-trials',
          '--ignore-gpu-blacklist',
          '--ignore-certificate-errors',
          '--ignore-certificate-errors-spki-list',
          '--disable-default-apps',
          '--enable-features=NetworkService',
          '--no-first-run',
          '--no-zygote',
          '--unlimited-storage',
          '--headless=new',
          '--disable-dev-shm-usage',
        ],
        headless: true,
        ignoreHTTPSErrors: true,
      }
@masarbazi
Copy link

Same issue🥲 no updates?

@frinyvonnick
Copy link
Owner

Did you check the troubleshooting section of Puppeteer documentation https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md? Since, I updated Puppeteer you might do some changes on your part. That is why I made a major version to warn about the fact it might contains breaking changes on puppeteer side.

@frinyvonnick frinyvonnick added the question Further information is requested label Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants