Puppeteer not running in headless:false mode Puppeteer not running in headless:false mode google-chrome google-chrome

Puppeteer not running in headless:false mode


1. You have to install some lib package.

gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 \ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget \xvfb x11vnc x11-xkb-utils xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic x11-apps

2.Then start xvfb with your script

Example:

xvfb-run --server-args="-screen 0 1024x768x24" npm start

If you using Docker then follow this docker file

FROM node:8RUN apt-get update && \apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 \ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget \xvfb x11vnc x11-xkb-utils xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic x11-appsWORKDIR /appCOPY package.json /appRUN npm installCOPY . /appEXPOSE 8081CMD xvfb-run --server-args="-screen 0 1024x768x24" npm start

Here is an example of puppeteer with xvfbhttps://github.com/nsourov/Puppeteer-with-xvfb


You can try tricking headless chrome to run with the GPU enabled:

const browser = await puppeteer.launch({   headless: false,   args: ['--headless'], })


For me it works:

const puppeteer = require('puppeteer');(async () => {        const browser = await puppeteer.launch({ headless: false });        console.log(await browser.userAgent());        await browser.close();})();