Docker NodeJS Puppeteer@2.0.0 - How do fix Failed to launch chrome! issue

你。 提交于 2020-12-13 03:03:24

问题


Without setting PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true and CHROMIUM_PATH /usr/bin/chromium-browser Without chromium package

Error for printPdf()
Error: Failed to launch chrome! spawn /usr/src/app/node_modules/puppeteer/.local-chromium/linux-706915/chrome-linux/chrome ENOENT


With setting PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true and CHROMIUM_PATH /usr/bin/chromium-browser With chromium package

Error is missing photos sometimes

Below is my Dockerfile:

FROM alpine:latest

WORKDIR /usr/src/app

RUN chmod -R 444 /etc/apk/
RUN echo "ipv6" >> /etc/modules

RUN set -x \
    && apk update \
    && apk upgrade \
RUN apk add -f

ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD true
ENV CHROMIUM_PATH /usr/bin/chromium-browser

# Installs latest Chromium package.
RUN apk add --no-cache \
    chromium \ ### with this, it is okay
    nss \
    freetype \
    freetype-dev \
    harfbuzz \
    ca-certificates \
    ttf-freefont \
    nodejs \
    npm \
    yarn

RUN yarn add puppeteer@2.0.0 adal-node@0.2.0 azure-keyvault@3.0.4 azure-sb@0.11.1 azure-storage@2.10.3 http@0.0.0

COPY package*.json ./

EXPOSE 3000

CMD [ "npm", "start"]

Below is my puppeteer.js:

browser = await puppeteer.launch({
    executablePath: '/usr/bin/chromium-browser', // if without using chromium package: executablePath: process.env.CHROMIUM_PATH,
    args: ['--no-sandbox', '--enable-font-antialiasing', '--font-render-hinting=medium'],
    timeout: LOAD_TIMEOUT,
    headless: true
});

Reference: GoogleChrome/puppeteer


回答1:


Just make the headless value to false

browser = await puppeteer.launch({
  headless: true
});


来源:https://stackoverflow.com/questions/58746052/docker-nodejs-puppeteer2-0-0-how-do-fix-failed-to-launch-chrome-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!