[Bug] Error: An `executablePath` or `channel` must be specified for `puppeteer-core`

See original GitHub issue

Describe the bug

  1. Fresh installation with : npm install puppeteer puppeteer-extra puppeteer-extra-plugin-stealth

  2. Copy paste the main from puppeteer-extra-plugin-stealth npm

  3. Start the program with node index.js

  4. I get the error Error: An 'executablePath' or 'channel' must be specified for 'puppeteer-core': image

Code Snippet

// puppeteer-extra is a drop-in replacement for puppeteer,
// it augments the installed puppeteer with plugin functionality
const puppeteer = require('puppeteer-extra');

// add stealth plugin and use defaults (all evasion techniques)
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
puppeteer.use(StealthPlugin());

// puppeteer usage as normal
puppeteer.launch({ headless: true }).then(async browser => {
  console.log('Running tests..')
  const page = await browser.newPage()
  await page.goto('https://bot.sannysoft.com')
  await page.waitForTimeout(5000)
  await page.screenshot({ path: 'testresult.png', fullPage: true })
  await browser.close()
  console.log(`All done, check the screenshot. ✨`)
});

Versions

  System:
    OS: Windows 10 10.0.19044
    CPU: (8) x64 Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
    Memory: 8.58 GB / 15.95 GB
  Binaries:
    Node: 16.13.2 - D:\Program Files\nodejs\node.EXE
    npm: 8.1.2 - D:\Program Files\nodejs\npm.CMD
  npmPackages:
    puppeteer: ^19.1.0 => 19.1.0
    puppeteer-extra: ^3.3.4 => 3.3.4
    puppeteer-extra-plugin-stealth: ^2.11.1 => 2.11.1

=================================== Edit So it seems that puppeteer-core require now the executablePath as mandatory? I think this is new I never got this error before.

I fixed it by adding the path to the chrome.exe file:

const os = require("os");
// puppeteer-extra is a drop-in replacement for puppeteer,
// it augments the installed puppeteer with plugin functionality
const puppeteer = require('puppeteer-extra');

// add stealth plugin and use defaults (all evasion techniques)
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
puppeteer.use(StealthPlugin());

// puppeteer usage as normal
puppeteer.launch({ headless: true, executablePath: `${os.homedir()}/.cache/puppeteer/chrome/win64-1045629/chrome-win/chrome.exe`}).then(async browser => {
  console.log('Running tests..')
  const page = await browser.newPage()
  await page.goto('https://bot.sannysoft.com')
  await page.waitForTimeout(5000)
  await page.screenshot({ path: 'testresult.png', fullPage: true })
  await browser.close()
  console.log(`All done, check the screenshot. ✨`)
});

Maybe puppeteer-extra could look for the presence of a browser in the cache and automatically find the installed one ? Probably linked with #728

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:8
  • Comments:6

github_iconTop GitHub Comments

27reactions
M4FFScommented, Oct 25, 2022

Thanks @bribes, this worked for me:

import { executablePath } from 'puppeteer';
import puppeteer from 'puppeteer-extra';

  const browser = await puppeteer.launch({
    headless: true,
    executablePath: executablePath(),
  });
  
17reactions
bribescommented, Oct 25, 2022

Same here

Edit:

Solutions:

Read more comments on GitHub >

github_iconTop Results From Across the Web

Puppeteer error: An `executablePath` or `channel` must be ...
It seems like puppeteer-core now requires executablePath as mandatory. Try this: import bypass from './captcha/captchaBypasser.js'; import ...
Read more >
Can't use puppeteer-core anymore due to error _projectRoot ...
Bug description I am using Puppeteer within WebdriverIO to run ... or puppeteer.launch with an explicit executablePath or channel option.
Read more >
Puppeteer-core NPM
PUPPETEER_EXECUTABLE_PATH - specify an executable path to be used in puppeteer.launch . PUPPETEER_PRODUCT - specify which browser you'd like Puppeteer to use.
Read more >
Puppeteer error: An `executablePath` or `channel ... - YouTube
Puppeteer error: An `executablePath` or `channel ` must be specified for `puppeteer - core ` I hope you found a solution that worked...
Read more >
Troubleshooting - Puppeteer
The most common cause is a bug in Node.js v14.0.0 which broke extract-zip , the module Puppeteer uses to extract browser downloads into...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found