Launching Chrome with Puppeteer (not Chromium)

Viewed 10265

I tried to launch chrome with puppeteer but it gave me this error

Error: Failed to launch the browser process! spawn //C://Program Files (x86)//Google//Chrome//Application ENOENT

This is the code I used

const puppeteer = require('puppeteer')
const browser = await puppeteer.launch( { headless: false,
        executablePath: '//C://Program Files (x86)//Google//Chrome//Application' })

So how can I launch chrome with puppeteer?

3 Answers

The path you gave is invalid in this format. If you are on Windows (which I suppose based on your currently given path) (1) you should use double backslashes \\, (2) but you shouldn't start your path with slashes nor backslashes. (3) Also you need the exact executable file as well at the end: chrome.exe.

The process goes like this: You can retrieve the exact executable path at your Chrome's chrome://version/ page, then you just need to escape each backslashes with another backslashes.

Correct usage:

C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe

I'd like to add, perhaps what you want is using the package chrome-launcher which takes care of running the chrome browser.

You can then use puppeteer.connect() to connect the puppeteer-core library to the browser opened and instrument it.

This is what worked for me on Windows

 const browser = await puppeteer.launch({
    headless: false,
    executablePath: 'C:/Program Files/Google/Chrome/Application/chrome.exe',
})

The slashes should be forward facing

Related