Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
oom- opened this issue Oct 23, 2022 · 10 comments
Open
Labels
issue: bug report A bug has been reported needs triage

Comments

@oom-
Copy link

oom- commented Oct 23, 2022

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: #730 (comment)

@oom- oom- added issue: bug report A bug has been reported needs triage labels Oct 23, 2022
@vgoklani
Copy link

vgoklani commented Oct 24, 2022

"win64-1045629"

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

I have the same problem too

@hamransp
Copy link

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

@yerbacode
Copy link

Same here

@alextim
Copy link

alextim commented Oct 24, 2022

Same error

@bribes
Copy link

bribes commented Oct 24, 2022

Same here

Edit:

Solutions:

@C-o-d-e-C-o-w-b-o-y
Copy link

Thanks @bribes, this worked for me:

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

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

@rothnic
Copy link

rothnic commented Feb 23, 2023

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.

@kanran111
Copy link

Same here

Edit:

Solutions:

oh man you save my day

@MrMegamind
Copy link

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

@chouzzy
Copy link

chouzzy commented Mar 28, 2024

Same here

Edit:

Solutions:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug report A bug has been reported needs triage
Projects
None yet
Development

No branches or pull requests