node-html-to-image icon indicating copy to clipboard operation
node-html-to-image copied to clipboard

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

Open brickyang opened this issue 2 years ago • 5 comments

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,
      }

brickyang avatar Nov 17 '23 09:11 brickyang

Same issue🥲 no updates?

masarbazi avatar Jun 18 '24 11:06 masarbazi

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 avatar Sep 09 '24 08:09 frinyvonnick

The same things happened to me, In my case node-html-to-image was used in node server, ever thing is ok by locally run but not in deploying, I don't know what's going on.

`Could not find Chrome (ver. 128.0.6613.119). This can occur if either

  1. you did not perform an installation before running the script (e.g. npx puppeteer browsers install ${browserType}) 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. (/opt/bytefaas/toutiao/app/gdserver/node_modules/.pnpm/[email protected][email protected]/node_modules/puppeteer-cluster/dist/Cluster.js:119:23) at Generator.throw () at rejected (/opt/bytefaas/toutiao/app/gdserver/node_modules/.pnpm/[email protected][email protected]/node_modules/puppeteer-cluster/dist/Cluster.js:6:65) `

package detail & use case "node-html-to-image": "^5.0.0"

image

qiaolee1024 avatar Dec 20 '24 08:12 qiaolee1024

same issues

QC2168 avatar Mar 27 '25 11:03 QC2168

same issues

any resolutions? Looking to resolve myself.

sk-matt avatar Apr 03 '25 17:04 sk-matt