0

As per the documentation https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#puppeteer-vs-puppeteer-core, I am trying to use puppeteer-core library instead of puppeteer so that I can install headless-shell instead of default chromium lib that comes with puppeteer.

I download the content-shell.zip for mac from this location https://chromium.cypress.io/mac/canary/89.0.4342.2 and used the below code,

const browser = await puppeteer.launch({executablePath: 'content-shell' });

it fails with the below error, Error: Failed to launch the browser process! spawn content-shell ENOENT

TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

at onClose (/Users/ln/mine/sandbox/puppeteer-test/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserRunner.js:193:20)
at ChildProcess.<anonymous> (/Users/ln/mine/sandbox/puppeteer-test/node_modules/puppeteer-core/lib/cjs/puppeteer/node/BrowserRunner.js:185:85)
at ChildProcess.emit (events.js:315:20)
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
at onErrorNT (internal/child_process.js:465:16)

where to get the headless-shell of chrome for mac, windows and linux versions?

Lokn
  • 421
  • 3
  • 16

2 Answers2

0

There is no separate binary/executable that runs chrome in headless. However, if you are running chrome version 59 or more in Mac and Linux and 60 or more for Windows, which is very likely (seeing the latest version is around 90), using the following should launch chrome in a headless state:

const browser = await puppeteer.launch({
    executablePath: '/path/to/chrome/executable', 
    args: ['--headless']
});

The executable for Mac can generally be found in the application's Contents/MacOS folder:

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome

For Linux, this might change basis the distribution. However, this might help find it.

Similarly, for Windows, the location changes with the version but this should help in finding it.

Kunal Kukreja
  • 662
  • 4
  • 13
0

According to docs, you have to build it yourself. Download Source Code.

... first initialize a headless build configuration:

$ mkdir -p out/Debug
$ echo 'import("//build/args/headless.gn")' > out/Debug/args.gn
$ gn gen out/Debug

Then build the example:

$ ninja -C out/Debug headless_example

After the build completes, the example can be run with the following command:

$ out/Debug/headless_example https://www.google.com
Faizan AlHassan
  • 369
  • 4
  • 6