I’m trying to deploy an application using Puppeteer with Docker, but I always get the same error: the browser is not found:
Error: Browser was not found at the configured executablePath (/usr/bin/google-chrome-stable)
throw new Error(`Browser was not found at the configured executablePath (${launchArgs.executablePath})`);
Even though I’m using the recommended image and modifying the browser path, I still get the same error. Is there anything I can do to deploy an application with Puppeteer using Docker? My application consists of using Puppeteer to generate PDFs, and it is built with NestJs.
Thank you!
I tried installing Chrome inside the container, referencing the official Puppeteer image, using puppeteer-core, but I always get the same error. Even when changing the executablePath, the error always remains the same, always referencing ‘/usr/bin/google-chrome-stable’.
Dockerfile:
# Base image
FROM ghcr.io/puppeteer/puppeteer:23.3.0
# Create app directory
WORKDIR /app
# A wildcard is used to ensure both package.json AND package-lock.json are copied
COPY package*.json ./
# Install app dependencies
RUN npm install
# Bundle app source
COPY . .
EXPOSE 4001
# Start the server using the production build
CMD ["npm", "run", "start:prod"]
Singleton of browser service:
async onModuleInit() {
const browserConfigs = {
headless: true,
args: ['--no-sandbox', '--disable-setuid-sandbox'],
browser: 'chrome',
} as puppeteer.PuppeteerLaunchOptions;
if (this.profile !== 'development') {
browserConfigs.executablePath = '/usr/bin/google-chrome-stable)';
}
this.browser = await puppeteer.launch(browserConfigs);
this.page = await this.browser.newPage();
this.page.setDefaultTimeout(0);
this.page.setDefaultNavigationTimeout(0);
}
Puppeteer version: 23.3.0
I’m trying to deploy an application using Puppeteer with Docker, but I always get the same error: the browser is not found:
Error: Browser was not found at the configured executablePath (/usr/bin/google-chrome-stable)
throw new Error(`Browser was not found at the configured executablePath (${launchArgs.executablePath})`);
Even though I’m using the recommended image and modifying the browser path, I still get the same error. Is there anything I can do to deploy an application with Puppeteer using Docker? My application consists of using Puppeteer to generate PDFs, and it is built with NestJs.
Thank you!
I tried installing Chrome inside the container, referencing the official Puppeteer image, using puppeteer-core, but I always get the same error. Even when changing the executablePath, the error always remains the same, always referencing ‘/usr/bin/google-chrome-stable’.
Dockerfile:
# Base image
FROM ghcr.io/puppeteer/puppeteer:23.3.0
# Create app directory
WORKDIR /app
# A wildcard is used to ensure both package.json AND package-lock.json are copied
COPY package*.json ./
# Install app dependencies
RUN npm install
# Bundle app source
COPY . .
EXPOSE 4001
# Start the server using the production build
CMD ["npm", "run", "start:prod"]
Singleton of browser service:
async onModuleInit() {
const browserConfigs = {
headless: true,
args: ['--no-sandbox', '--disable-setuid-sandbox'],
browser: 'chrome',
} as puppeteer.PuppeteerLaunchOptions;
if (this.profile !== 'development') {
browserConfigs.executablePath = '/usr/bin/google-chrome-stable)';
}
this.browser = await puppeteer.launch(browserConfigs);
this.page = await this.browser.newPage();
this.page.setDefaultTimeout(0);
this.page.setDefaultNavigationTimeout(0);
}
Puppeteer version: 23.3.0
Share Improve this question edited Nov 20, 2024 at 0:02 Samathingamajig 13.3k3 gold badges17 silver badges44 bronze badges asked Nov 19, 2024 at 22:06 Felipe Oliveira SousaFelipe Oliveira Sousa 212 bronze badges1 Answer
Reset to default 0This is happening because there is no google-chrome-stable inside the puppeteer docker image. To get the browser executable, you can simply use a nodejs script like below.
console.log(require('puppeteer').executablePath())
You can do the same for official docker image as per their documentation,
docker run -i --init --cap-add=SYS_ADMIN --rm \
ghcr.io/puppeteer/puppeteer:latest \
node -e "console.log(require('puppeteer').executablePath())"
This is going to print a location like below,
/home/pptruser/.cache/puppeteer/chrome/linux-131.0.6778.85/chrome-linux64/chrome
You do not have to provide any specific executablePath when using the official docker image. It's already installed there.