Alok
Alok

Reputation: 10664

How to find which chrome executable is getting used by Puppeteer?

// executablePath is specified
const browser = await puppeteer.launch({
  executablePath: '/path/to/chrome'
});

// // executablePath is not specified
const browser = await puppeteer.launch();
// This will not work. 
// console.log('executablePath is', browser.executablePath)

If we do not specify a value for the executablePath option, Puppeteer will try to find the default installation of Chrome or Chromium on the system. On Windows, this is usually C:\Program Files (x86)\Google\Chrome\Application\chrome.exe. On macOS and Linux, Puppeteer will try to use the chrome or chromium executable in the PATH.

How we can find out which executable is getting used by Puppetter in Puppeteer script itself?

Upvotes: 2

Views: 5270

Answers (2)

Otee
Otee

Reputation: 108

If you try using Puppeteer.executablePath() and it still does not work appropriately, then setup a config file in the root of your application to help puppeteer find the browser.

Upvotes: 0

Alok
Alok

Reputation: 10664

https://pptr.dev/api/puppeteer.puppeteernode.executablepath

const puppeteer = require('puppeteer')
console.log(puppeteer.executablePath())

Example output on my node-18 docker image is

root@021100c40ec4:/usr/src/app# node -e "console.log(require('puppeteer').executablePath())"
/root/.cache/puppeteer/chrome/linux-1069273/chrome-linux/chrome

Upvotes: 2

Related Questions