Buglesstack is in beta development. Get started

Could not find expected browser locally

Learn how to fix the 'Could not find expected browser locally' error in Puppeteer when the browser installation is missing or corrupted


Could not find expected browser locally

This error occurs when Puppeteer cannot find a compatible browser installation on your system. This is common when using puppeteer-core or when the browser installation is missing or corrupted.

Common Causes

  • Using puppeteer-core without browser: puppeteer-core doesn’t download browsers automatically
  • Corrupted browser installation: The browser files are incomplete or damaged
  • Incorrect browser path: The specified browser path is wrong
  • Version mismatch: Installed browser version doesn’t match Puppeteer’s requirements

Solutions

1. Use puppeteer instead of puppeteer-core

Switch from puppeteer-core to puppeteer to automatically download the browser:

// Remove puppeteer-core
// npm uninstall puppeteer-core

// Install puppeteer
// npm install puppeteer

const puppeteer = require('puppeteer');
const browser = await puppeteer.launch();

2. Specify the correct browser path

If using puppeteer-core, provide the correct browser path:

const browser = await puppeteer.launch({
  executablePath: '/path/to/your/chrome',
  // For Windows: 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe'
  // For macOS: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
  // For Linux: '/usr/bin/google-chrome'
});

3. Reinstall the browser

For Ubuntu/Debian:

# Remove existing installation
sudo apt-get remove google-chrome-stable

# Install fresh copy
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
sudo apt-get install -f

For macOS:

brew uninstall --cask google-chrome
brew install --cask google-chrome

4. Clear Puppeteer cache and reinstall

# Remove Puppeteer cache
rm -rf ~/.cache/puppeteer

# Reinstall Puppeteer
npm uninstall puppeteer
npm install puppeteer

Still Encountering Issues?

If you’re still having trouble finding the browser, you can use a visual testing tool like Buglesstack to debug your automation setup and verify browser configurations.

// .. assuming you already have your Puppeteer browser and page initialized

try {
	await page.goto('https://www.google.com/search?q=puppeteer');		
	await page.waitForSelector('[name="q"]');
}
catch (error) {
	// Prepare buglesstack data
	const buglesstackData = {
		url: page.url(),
		screenshot: await page.screenshot({ encoding: 'base64' }),
		html: await page.content(),
		metadata: {},
		message: error.message,
		stack: error.stack
	};

	// Get your access token from https://app.buglesstack.com
	const ACCESS_TOKEN = 'HERE_YOUR_ACCESS_TOKEN';

	// Send error to buglesstack
	await axios.post('https://app.buglesstack.com/api/v1/crashes', buglesstackData, {
		headers: {
			Authorization: `Bearer ${ACCESS_TOKEN}`,
			'Content-Type': 'application/json'
		}
	});
		
	// Re-throw the error to propagate it
	throw error;
}

By ensuring proper browser installation and configuration, you can resolve the “Could not find expected browser locally” error and get your automation running smoothly.

Save days debugging your
browser automation

Speed up production debugging with instant visualizations of your browser automation crashes.