How do I improve Chrome binary detection on Windows for Puppeteer?
PuppeteerAnswer
To fix Puppeteer not finding the Chrome binary on Windows, make sure the detector checks the common install locations:
- Program Files\Google\Chrome\Application\chrome.exe
- Program Files (x86)\Google\Chrome\Application\chrome.exe
- %HOMEDIR%\AppData\Local\Google\Chrome\Application\chrome.exe
Here is a simple Windows path finder you can adapt:
const fs = require('fs'); const path = require('path'); function fileExists(p){ try { return fs.existsSync(p); } catch { return false; } } function findChromeWindows(){ const candidates = [ 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe', 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe', '%USERPROFILE%\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe' ]; for (const c of candidates){ if (fileExists(c)) return c; } return null; } console.log(findChromeWindows());
This approach follows the common Windows installation paths and helps Puppeteer reliably locate the browser on Windows.