puppeteer-extra icon indicating copy to clipboard operation
puppeteer-extra copied to clipboard

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

Open oom- opened this issue 3 years ago • 10 comments
trafficstars

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

Edit: Use this answer for better fix: https://github.com/berstend/puppeteer-extra/issues/730#issuecomment-1289776341

oom- avatar Oct 23 '22 19:10 oom-

"win64-1045629"

are you going to update this each time the version changes? :)

I have the same problem too

vgoklani avatar Oct 24 '22 03:10 vgoklani

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

Same Problem

hamransp avatar Oct 24 '22 05:10 hamransp

Same here

yerbacode avatar Oct 24 '22 16:10 yerbacode

Same error

alextim avatar Oct 24 '22 18:10 alextim

Same here

Edit:

Solutions:

  • Setting executablePath: require('puppeteer').executablePath().
  • https://www.npmjs.com/package/puppeteer-chromium-resolver

bribes avatar Oct 24 '22 23:10 bribes

Thanks @bribes, this worked for me:

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

  const browser = await puppeteer.launch({
    headless: true,
    executablePath: executablePath(),
  });
  

C-o-d-e-C-o-w-b-o-y avatar Oct 25 '22 09:10 C-o-d-e-C-o-w-b-o-y

Any ideas for how to work around this issue if you can't leverage the full puppeteer in production? See the Sparticuz/chromium project to use headless chrome in a lambda function. None of the mentioned workarounds work for me.

I didn't test using https://www.npmjs.com/package/puppeteer-chromium-resolver, but that seems to download chromium, which is something already handled by the Sparticuz/chromium project.

I did try using executablePath: require('puppeteer').executablePath(), but instead like executablePath: require('puppeteer-core').executablePath(). That results in an error of _projectRoot is undefined. Unable to create a BrowserFetcher.

rothnic avatar Feb 23 '23 00:02 rothnic

Same here

Edit:

Solutions:

  • Setting executablePath: require('puppeteer').executablePath().
  • https://www.npmjs.com/package/puppeteer-chromium-resolver

oh man you save my day

kanran111 avatar Mar 29 '23 17:03 kanran111

For me, I had to:

  1. npm cache clean --force
  2. Delete C:\Users\Administrator.cache\puppeteer
  3. Delete node_modules folder (npm remove puppeteer might also work but did not try)
  4. Run npm install

Everything fixed.

I have no idea what was issue but this helped me finally after going through all above

MrMegamind avatar Dec 20 '23 11:12 MrMegamind

Same here

Edit:

Solutions:

  • Setting executablePath: require('puppeteer').executablePath().
  • https://www.npmjs.com/package/puppeteer-chromium-resolver

Worked for me, 12h trying to fix this, you helped me a lot, thanks mate :)

chouzzy avatar Mar 28 '24 16:03 chouzzy