narcisse
narcisse

Reputation: 451

Launching Chrome with Puppeteer (not Chromium)

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?

Upvotes: 9

Views: 29569

Answers (4)

Lightrdrdlight
Lightrdrdlight

Reputation: 11

If I understand you correctly, then try:

browser = await puppeteer.launch({      
      channel: 'chrome'
})

Upvotes: 1

sean 2000
sean 2000

Reputation: 91

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

Upvotes: 7

Félix
Félix

Reputation: 154

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.

Upvotes: 1

theDavidBarton
theDavidBarton

Reputation: 8841

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

Upvotes: 8

Related Questions