16
  • Puppeteer version : 1.11.0
  • Platform / OS version: Windows 10 pro
  • Node.js version: 12.6.6

When I did a local development test in windows, happen was problem in executablePath.

"Failed to launch chrome! spawn /usr/bin/chromium-browser ENOENT"

I saw for windows needs to get complete path. Otherwise cannot find chrome.exe

Default in code:

const browser = await puppeteer.launch({executablePath: '/path/to/Chrome'});

In windows it worked thus:

const browser = await puppeteer.launch({executablePath: 'C:\\your_workspace\\node_modules\\puppeteer\\.local-chromium\\win64-(version)\\chrome-win\\chrome.exe'});

In visual code suggest the path

Visual Code view explorer

1
  • I confirm that's solution worked correctly in my case
    – Nellonidas
    Commented Jan 28, 2020 at 12:21

2 Answers 2

14

You can also set the environment variable PUPPETEER_EXECUTABLE_PATH.

This is useful in conjunction with PUPPETEER_SKIP_CHROMIUM_DOWNLOAD set to true

1
  • thank you for this env tip i can use now chrome as background browser :D Commented Jul 7, 2021 at 6:45
11

Maybe this can help:

const osPlatform = os.platform(); // possible values are: 'darwin', 'freebsd', 'linux', 'sunos' or 'win32'
console.log('Scraper running on platform: ', osPlatform);
let executablePath;
if (/^win/i.test(osPlatform)) {
  executablePath = '';
} else if (/^linux/i.test(osPlatform)) {
  executablePath = '/usr/bin/google-chrome';
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.