microsoft/playwright · error · Error
Electron executablePath not found! Please install it using `
Error message
Electron executablePath not found! Please install it using `npm install -D electron` or set the executablePath to your Electron executable.
What it means
electron.launch() needs the Electron executable. When no executablePath is provided it tries require('electron/index.js'), which the `electron` npm package resolves to its binary path. If the package is not installed, Node throws MODULE_NOT_FOUND and Playwright re-throws a boxed message telling you to install electron or pass executablePath.
Source
Thrown at packages/playwright-core/src/server/electron/electron.ts:211
artifactsDir = options.artifactsDir;
} else {
artifactsDir = await progress.race(fs.promises.mkdtemp(ARTIFACTS_FOLDER));
tempDirectories.push(artifactsDir);
}
const browserLogsCollector = new RecentLogsCollector();
const env = options.env ? envArrayToObject(options.env) : process.env;
let command: string;
if (options.executablePath) {
command = options.executablePath;
} else {
try {
// By default we fallback to the Electron App executable path.
// 'electron/index.js' resolves to the actual Electron App.
command = require('electron/index.js');
} catch (error: any) {
if ((error as NodeJS.ErrnoException)?.code === 'MODULE_NOT_FOUND') {
throw new Error('\n' + wrapInASCIIBox([
'Electron executablePath not found!',
'Please install it using `npm install -D electron` or set the executablePath to your Electron executable.',
].join('\n'), 1));
}
throw error;
}
// Only use our own loader for non-packaged apps.
// Packaged apps might have their own command line handling.
electronArguments.unshift('-r', libPath('server', 'electron', 'loader.js'));
}
let shell = false;
if (process.platform === 'win32') {
// On Windows in order to run .cmd files, shell: true is required.
// https://github.com/nodejs/node/issues/52554
shell = true;
// On Windows, we need to quote the executable path and arguments due to shell: true.
// We allso pass the arguments as a single string due to DEP0190,
// see https://github.com/microsoft/playwright/issues/38278.View on GitHub (pinned to c8fc3bf8d3)
Solutions
- Install Electron as a dev dependency: npm install -D electron.
- Pass executablePath pointing at an existing Electron binary: electron.launch({ executablePath: '/path/to/electron' }).
- If using a monorepo, ensure electron is resolvable from the workspace running the tests (add it locally or fix hoisting).
- Re-run npm install after adding electron to package.json.
Example fix
// before const app = await electron.launch(); // electron not installed → throws // after // shell: npm install -D electron const app = await electron.launch();
Defensive patterns
Strategy: validation
Validate before calling
// Check electron is resolvable before launching.
try {
require.resolve('electron');
} catch {
throw new Error('Run `npm install -D electron` first');
}
const app = await electron.launch(); Prevention
- Add electron as a devDependency in every workspace that runs Electron tests.
- Pass executablePath explicitly when relying on a system Electron install.
- After fresh checkouts, run a full npm install before Electron tests.
When it happens
Trigger: Calling electron.launch() in a project that has not installed the `electron` npm dependency and does not pass executablePath; monorepo where electron is hoisted/resolved in a different workspace; CI that installs only @playwright/test without electron.
Common situations: New Electron testing setup missing `npm i -D electron`; pnpm/yarn workspace hoisting preventing the require from resolving; a fresh checkout where devDependencies were installed with --production.
Related errors
- Launching more browsers is not allowed.
- Unable to open X display! ================================ M
- No Mobile Safari tabs found at ${this._proxyBase}/json — ope
- Playwright Extension not found in "${userDataDir}". Install
- Skill source directory not found: ${sourceDir}
AI-assisted analysis of microsoft/playwright@c8fc3bf8d3 (2026-08-12).
Data as JSON: /api/errors/eef4aa24da9703f6.
Report an issue: GitHub.