DaiKeung
DaiKeung

Reputation: 1167

Docker NodeJS [email protected] - How do fix Failed to launch chrome! issue

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 sometimesenter image description here

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 [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]

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

Upvotes: 1

Views: 4475

Answers (1)

Rasoamanana Diamondra
Rasoamanana Diamondra

Reputation: 24

Just make the headless value to false

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

Upvotes: 0

Related Questions