{"record":{"id":"eef4aa24da9703f6","repo":"microsoft/playwright","slug":"electron-executablepath-not-found-please-install","errorCode":null,"errorMessage":"Electron executablePath not found!\nPlease install it using `npm install -D electron` or set the executablePath to your Electron executable.","messagePattern":"Electron executablePath not found!\nPlease install it using `npm install -D electron` or set the executablePath to your Electron executable\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/server/electron/electron.ts","lineNumber":211,"sourceCode":"      artifactsDir = options.artifactsDir;\n    } else {\n      artifactsDir = await progress.race(fs.promises.mkdtemp(ARTIFACTS_FOLDER));\n      tempDirectories.push(artifactsDir);\n    }\n    const browserLogsCollector = new RecentLogsCollector();\n    const env = options.env ? envArrayToObject(options.env) : process.env;\n\n    let command: string;\n    if (options.executablePath) {\n      command = options.executablePath;\n    } else {\n      try {\n        // By default we fallback to the Electron App executable path.\n        // 'electron/index.js' resolves to the actual Electron App.\n        command = require('electron/index.js');\n      } catch (error: any) {\n        if ((error as NodeJS.ErrnoException)?.code === 'MODULE_NOT_FOUND') {\n          throw new Error('\\n' + wrapInASCIIBox([\n            'Electron executablePath not found!',\n            'Please install it using `npm install -D electron` or set the executablePath to your Electron executable.',\n          ].join('\\n'), 1));\n        }\n        throw error;\n      }\n      // Only use our own loader for non-packaged apps.\n      // Packaged apps might have their own command line handling.\n      electronArguments.unshift('-r', libPath('server', 'electron', 'loader.js'));\n    }\n    let shell = false;\n    if (process.platform === 'win32') {\n      // On Windows in order to run .cmd files, shell: true is required.\n      // https://github.com/nodejs/node/issues/52554\n      shell = true;\n      // On Windows, we need to quote the executable path and arguments due to shell: true.\n      // We allso pass the arguments as a single string due to DEP0190,\n      // see https://github.com/microsoft/playwright/issues/38278.","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/server/electron/electron.ts#L193-L229","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nconst app = await electron.launch(); // electron not installed → throws\n// after\n// shell: npm install -D electron\nconst app = await electron.launch();","handlingStrategy":"validation","validationCode":"// Check electron is resolvable before launching.\ntry {\n  require.resolve('electron');\n} catch {\n  throw new Error('Run `npm install -D electron` first');\n}\nconst app = await electron.launch();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["electron","setup","dependency"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}