How can I resolve the "An executablePath or channel must be specified" error in Puppeteer when launching a browser?

Is there a way to set the executablePath in Puppeteer to avoid the error “An executablePath or channel must be specified”?

I’m trying to make a simple Puppeteer project. My current code is just a test. It doesn’t work though.

import bypass from ‘./captcha/captchaBypasser.js’; import {createRequire} from “module”;

const require = createRequire(import.meta.url);

const puppeteer = require(‘puppeteer-extra’); const hidden = require(‘puppeteer-extra-plugin-stealth’)

test()

async function test() {

// Launch sequence puppeteer.use(hidden()) const browser = await puppeteer.launch({ args: [‘–no-sandbox’,], headless: false, ignoreHTTPSErrors: true })

const page = await browser.newPage() await page.setViewport({ width: 1920, height: 1280, deviceScaleFactor: 1, });

//Go to page await page.goto(‘https://google.com/’, { waitUntil: ‘networkidle0’, }); } I searched around for an explanation but it seems like I am the only one getting this error

    throw new Error(message);
          ^

Error: An executablePath or channel must be specified for puppeteer-core at assert (C:\Users\Julian\Desktop\project\node_modules\puppeteer-core\lib\cjs\puppeteer\util\assert.js:28:15) at ChromeLauncher.launch (C:\Users\Julian\Desktop\project\node_modules\puppeteer-core\lib\cjs\puppeteer\node\ChromeLauncher.js:69:36) at PuppeteerNode.launch (C:\Users\Julian\Desktop\project\node_modules\puppeteer-core\lib\cjs\puppeteer\node\PuppeteerNode.js:154:105) at PuppeteerExtra.launch (C:\Users\Julian\Desktop\project\node_modules\puppeteer-extra\dist\index.cjs.js:128:41) at async test (file:///C:/Users/Julian/Desktop/project/test.js:21:19)

Node.js v18.12.0 I was expecting a Puppeteer instance to pop up and go to google.com. Instead, I got an error.

Hi Kalyani

Hope this answer works for you

It seems like puppeteer-core now requires executablePath as mandatory.

Try this:

import bypass from ‘./captcha/captchaBypasser.js’;

import {createRequire} from “module”; const require = createRequire(import.meta.url);

const puppeteer = require(‘puppeteer-extra’); const hidden = require(‘puppeteer-extra-plugin-stealth’)

// require executablePath from puppeteer const {executablePath} = require(‘puppeteer’)

test()

async function test() {

// Launch sequence puppeteer.use(hidden()) const browser = await puppeteer.launch({ args: [‘–no-sandbox’,], headless: false, ignoreHTTPSErrors: true,

// add this
executablePath: executablePath(),

})

const page = await browser.newPage() await page.setViewport({ width: 1920, height: 1280, deviceScaleFactor: 1, });

// Go to page await page.goto(‘https://google.com/’, { waitUntil: ‘networkidle0’, }); }