DEV Community

Tony Stark
Tony Stark

Posted on • Edited on

Fix Electron failed to install correctly on Windows

If you are on Windows and an Electron app stops with this error:

Electron failed to install correctly, please delete node_modules/electron and try installing again
Enter fullscreen mode Exit fullscreen mode

the important detail is usually this:

node_modules/electron can exist while the actual Electron binary is missing.

So a blind npm install retry is not always enough. First check whether the package folder exists and whether electron.exe was actually downloaded.

Fast path: check this before reinstalling everything

In the project folder, run this first:

Test-Path .\package.json
Test-Path .\node_modules\electron
Test-Path .\node_modules\electron\dist\electron.exe
Enter fullscreen mode Exit fullscreen mode

The key line is the third one.

If node_modules\electron is True but node_modules\electron\dist\electron.exe is False, the package is present but the Electron binary is missing. In that case, start with the targeted Electron reinstall below before deleting the whole node_modules folder.

1. Confirm you are in the project folder

Open PowerShell in the project folder and run:

Get-Location
Test-Path .\package.json
Test-Path .\node_modules\electron
Enter fullscreen mode Exit fullscreen mode

You want:

True
True
Enter fullscreen mode Exit fullscreen mode

for package.json and node_modules\electron.

If package.json is False, you are in the wrong folder. Move to the app folder first.

2. Check the actual Electron binary

Now check the binary:

Test-Path .\node_modules\electron\dist\electron.exe
Enter fullscreen mode Exit fullscreen mode

If this returns False, Electron's package directory exists, but the install hook or binary download did not complete.

That is the state that often triggers:

Electron failed to install correctly
Enter fullscreen mode Exit fullscreen mode

Common reasons on Windows:

  • the Electron postinstall step was interrupted;
  • the Electron binary download was blocked by a network, antivirus, corporate proxy, or TLS inspection;
  • npm install ran in an old terminal after Node.js or PATH changed;
  • the app also has native modules, so the Electron error is the first visible failure but not the only broken layer.

3. Try the targeted repair first

Before deleting all node_modules, try the smaller fix:

Remove-Item -Recurse -Force .\node_modules\electron
npm install
Enter fullscreen mode Exit fullscreen mode

Then check again:

Test-Path .\node_modules\electron\dist\electron.exe
Enter fullscreen mode Exit fullscreen mode

If it returns True, retry your app:

npm run dev
Enter fullscreen mode Exit fullscreen mode

4. If Electron still does not install, check Node and npm

Run:

node -v
npm -v
where node
where npm
Enter fullscreen mode Exit fullscreen mode

On Windows, a fresh Node.js install can update PATH, but the old PowerShell window may not see the change yet.

If node works but npm does not, close PowerShell and open a new one before reinstalling anything.

5. If native modules are involved, do not guess

Electron apps often include native packages such as:

  • better-sqlite3
  • node-gyp
  • Windows key listeners
  • SQLite bindings

Those packages can require prebuilt binaries or local build tools.

Check what is actually present:

npm ls better-sqlite3
npm ls node-gyp
Enter fullscreen mode Exit fullscreen mode

If the project needs a local build, Windows may need Visual Studio Build Tools. But do not install the whole toolchain blindly. First confirm the package that is failing and whether a prebuilt binary exists for your Node/Electron version.

6. Free layered diagnostic script

I published a small read-only diagnostic script for this class of Windows setup problems:

GitHub: WiaiKit Windows AI Coding Setup Repair

It now checks the setup by layer:

  • Runtime: Node.js, npm, PATH
  • Project: package.json, node_modules
  • Electron: package folder, electron.exe, install hook
  • Native modules: better-sqlite3, key listeners, node-gyp
  • Build Tools: Visual Studio C++ toolchain
  • Voice stack: Windows audio, WSL, Codex, Claude Code indicators

Run it from the project folder:

powershell -ExecutionPolicy Bypass -File .\wiaikit-windows-ai-coding-setup-check.ps1
Enter fullscreen mode Exit fullscreen mode

Or pass the project path:

powershell -ExecutionPolicy Bypass -File .\wiaikit-windows-ai-coding-setup-check.ps1 -ProjectPath C:\path\to\your\project
Enter fullscreen mode Exit fullscreen mode

The script does not install, delete, or modify files. It prints OK, CHECK, BROKEN, and NEXT ACTION lines so you can stop guessing which layer failed.

Browser version:

Run the free Windows AI coding setup diagnostic

7. My usual recovery order

For this specific error, I would use this order:

  1. Confirm the folder has package.json.
  2. Check node_modules\electron.
  3. Check node_modules\electron\dist\electron.exe.
  4. Delete only node_modules\electron.
  5. Run npm install.
  6. Only then consider a full node_modules reinstall.
  7. If native modules fail, inspect node-gyp, Visual Studio Build Tools, and the exact package.

This avoids the common Windows loop of reinstalling everything without knowing what actually broke.

Related diagnostic page

I also keep the same fix as a shorter checklist here:

Fix Electron failed to install correctly on Windows

The paid WiaiKit repair kit is the longer recovery path after the diagnostic tells you which layer is broken: npm PATH, Electron, node-gyp, Visual Studio Build Tools, native modules, OpenWhispr, Codex, Claude Code, and push-to-talk voice workflows.

For this specific Electron error, start with the free diagnostic above.

Top comments (0)