puppeteer-extra
puppeteer-extra copied to clipboard
[Bug] Error: An `executablePath` or `channel` must be specified for `puppeteer-core`
Describe the bug
-
Fresh installation with :
npm install puppeteer puppeteer-extra puppeteer-extra-plugin-stealth -
Copy paste the main from
puppeteer-extra-plugin-stealthnpm -
Start the program with
node index.js -
I get the error
Error: An 'executablePath' or 'channel' must be specified for 'puppeteer-core':
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
"win64-1045629"
are you going to update this each time the version changes? :)
I have the same problem too
Describe the bug
- Fresh installation with :
npm install puppeteer puppeteer-extra puppeteer-extra-plugin-stealth- Copy paste the main from
puppeteer-extra-plugin-stealthnpm- Start the program with
node index.js- I get the error
Error: An 'executablePath' or 'channel' must be specified for 'puppeteer-core':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
executablePathas mandatory? I think this is new I never got this error before.I fixed it by adding the path to the
chrome.exefile: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
Same here
Same error
Same here
Edit:
Solutions:
- Setting
executablePath: require('puppeteer').executablePath(). - https://www.npmjs.com/package/puppeteer-chromium-resolver
Thanks @bribes, this worked for me:
import { executablePath } from 'puppeteer';
import puppeteer from 'puppeteer-extra';
const browser = await puppeteer.launch({
headless: true,
executablePath: executablePath(),
});
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.
Same here
Edit:
Solutions:
- Setting
executablePath: require('puppeteer').executablePath().- https://www.npmjs.com/package/puppeteer-chromium-resolver
oh man you save my day
For me, I had to:
- npm cache clean --force
- Delete C:\Users\Administrator.cache\puppeteer
- Delete node_modules folder (npm remove puppeteer might also work but did not try)
- Run npm install
Everything fixed.
I have no idea what was issue but this helped me finally after going through all above
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 :)