Troubleshooting
Also see Rsbuild troubleshooting and the Rspack FAQ. If these tips are not enough, search or open an issue on GitHub.
Tips
- During development — use breakpoints or
debugger. - Before packaging — run
rselectron previewto catch production-build issues early. - Check config — run
rselectron inspect --format humanbefore chasing compiler or launch failures. Inspect shows normalized, Rsbuild, and Rspack layers — see JavaScript API · inspect and CLI. - Close handles — always call
close()on handles fromcreateServer/build/preview; repeated calls are safe.
Development
Electron not found
Code: RSELECTRON_ELECTRON_NOT_FOUND
Install Electron at the project root (or ensure the selected manifest resolves to a project-local install). Rselectron does not download Electron for you. Supported versions: Compatibility.
Missing main / preload / renderer config
Code / warning: RSELECTRON_ROLE_MISSING
Omitting a process on purpose is allowed. If you expected it to build, add the matching key under defineConfig. See Main, preload, and renderer.
--renderer-only will not start
--renderer-only skips main and preload builds and reuses prior outputs. Run a full rselectron dev (or build) at least once first, and keep those outputs valid. Do not keep using this flag after changing main or preload sources. Flag details: CLI.
Renderer looks like a Node / Electron Renderer target
When the renderer target looks like Node, electron*-main|preload, or an explicit electron-renderer / electron*-renderer, Rselectron emits RSELECTRON_RENDERER_NODE_INTEGRATION_RISK. The default sandboxed path derives output.overrideBrowserslist: ['chrome >= ${min(M, 138)}'] from the Electron support snapshot (clamped to today's browserslist-rs ceiling; see browserslist-rs#48). Rsbuild then composes a web + browserslist Rspack target. You can still set tools.rspack.target: 'web' explicitly as an escape hatch. Unless you intentionally enable nodeIntegration, do not override with a hand-written electron*-renderer.
Config change restarts everything
A watched configuration dependency change reloads the whole configuration generation and replaces the development session. Partial hot replacement of config is not supported — see Concepts.
Build
build rejects watch
Production build is finite and does not support process-selective watch (RSELECTRON_BUILD_WATCH_UNSUPPORTED). For main / preload hot reload use:
See CLI.
Import-only package fails under CJS main / preload
Code / warning: RSELECTRON_IMPORT_ONLY_EXTERNAL
Symptoms: the Main or Preload build succeeds, but Electron fails at launch or first use with ERR_REQUIRE_ESM, is not a function, or a similar require of an ESM-only module. This happens when the role format is CJS and format-aware externalization emits a CommonJS external for an import-only package (or subpath). Rspack may rewrite static or dynamic import to require; the break shows up only at runtime.
Primary fixes (Preferred ESM path first):
- Prefer
electron.format: 'esm', or leaveformat: 'auto'under"type": "module"so Main/Preload derive ESM. Remove a forcedformat: 'cjs'if it was only a workaround for ESM-only dependencies. - If you intentionally stay on CJS, bundle the package with
electron.externalizeDeps.include(see Electron options · externalizeDeps).
Coming from electron-vite: the same class of failure is documented as ERR_REQUIRE_ESM / ESM-only dependencies. electron-vite’s bundle escape is named exclude; in Rselectron the same intent is include—but only as the CJS-side escape, not the default recommendation.
Rselectron does not auto-include import-only packages. Bundler ignore comments (for example /* webpackIgnore: true */) are an advanced last resort and do not silence RSELECTRON_IMPORT_ONLY_EXTERNAL; drop them once you are on the Preferred ESM path.
Preview
Skip rebuilding
Use only when outputs are already up to date.

