Skip to content

Windows 11: fix npm install (node-pty MSB8040) and blank dev window (ERR_CONNECTION_REFUSED) - #9

Open
KorolevOl wants to merge 1 commit into
HelpFreedom:mainfrom
KorolevOl:fix/windows11-npm-install
Open

Windows 11: fix npm install (node-pty MSB8040) and blank dev window (ERR_CONNECTION_REFUSED)#9
KorolevOl wants to merge 1 commit into
HelpFreedom:mainfrom
KorolevOl:fix/windows11-npm-install

Conversation

@KorolevOl

Copy link
Copy Markdown

Two bugs that break the documented dev workflow (npm installnpm run dev) on Windows 11. Both reproduced and verified on the target machine (Windows 11, Node v24.19.0, Visual Studio 2022 Community, Windows SDK 10.0.19041/10.0.22621). Fixes prepared with Hermes Agent (Nous Research) running on qwen3.8:27b.

1) npm install fails: MSBuild error MSB8040 (Spectre mitigation libraries required)

Cause: postinstall runs electron-rebuild -f -w node-pty, which compiles node-pty from source. node-pty hard-codes SpectreMitigation='Spectre' in binding.gyp and deps/winpty/src/winpty.gyp, so MSBuild (Microsoft.CppBuild.targets:504) checks for the MSVC Spectre-mitigated libs VS component. On machines without that component (a common default VS install) the build of conpty/conpty_console_list/winpty-agent/winpty fails.
Fix: new scripts/fix-spectre.js (idempotent) flips SpectreMitigation to 'false' in both .gyp files before the rebuild, so the generator emits <SpectreMitigation>false</SpectreMitigation> and MSBuild skips /Qspectre and the existence check. package.json postinstall now runs it first:

"postinstall": "node scripts/fix-spectre.js && electron-rebuild -f -w node-pty"

Verified: clean rm -rf node_modules && npm install succeeds ("Rebuild Complete", 0 vulnerabilities) and the built .node binary loads inside Electron 42 (ABI 146).

2) npm run dev: blank Electron window, ERR_CONNECTION_REFUSED

Cause: the Vite dev server binds to localhost, which since Node ≥ 17 resolves to [::1] (IPv6) first — netstat showed the listener on [::1]:5173 only. The Electron renderer connects via 127.0.0.1 (IPv4), where nothing listens → connection refused → blank window.
Fix: electron.vite.config.ts renderer section now pins the dev server to the IPv4 loopback:

renderer: { server: { host: '127.0.0.1' } }

electron-vite then sets ELECTRON_RENDERER_URL to http://127.0.0.1:5173/.
Verified: dev log is error-free, netstat shows 127.0.0.1:5173 LISTENING, and the window renders the full Kadr UI (media panel, preview, properties, timeline V2/V1/A1).

3) Docs

README.md / README.en.md — "Windows" notes under Getting started explaining both failure modes, the repo-side workaround, and the alternative manual fix (install the MSVC v143 – C++ x64/x86 Spectre-mitigated libs component via Visual Studio Installer).

4) package-lock.json

Regenerated by the clean npm install used to verify fix 1 — npm re-resolved 104 transitive packages to their newest versions within the ^-ranges already declared in package.json (e.g. electron 42.4.0 → 42.9.2, rollup 4.61.1 → 4.62.4, esbuild 0.28.1 → 0.28.2, @electron/rebuild 4.0.4 → 4.2.0). No version-range changes in package.json.

Files

  • scripts/fix-spectre.js (new)
  • package.json (postinstall chain)
  • electron.vite.config.ts (IPv4 loopback bind)
  • README.md, README.en.md (Windows notes)
  • package-lock.json (regenerated)

…_CONNECTION_REFUSED at npm run dev
Two bugs that break the documented dev workflow (npm install → npm run dev)
on Windows 11. Both reproduced and verified on the target machine
(Windows 11, Node v24.19.0, Visual Studio 2022 Community, Windows SDK
10.0.19041/10.0.22621). All fixes were made by Hermes Agent (Nous Research)
running on qwen3.8:27b.
1) npm install fails with MSBuild error MSB8040 (Spectre mitigation libraries
required)
Cause: postinstall runs `electron-rebuild -f -w node-pty`, which
compiles node-pty from source. node-pty hard-codes
SpectreMitigation='Spectre' in binding.gyp and deps/winpty/src/winpty.gyp,
so MSBuild (Microsoft.CppBuild.targets:504) checks for the MSVC
"Spectre-mitigated libs" VS component. On machines without that
component (common default VS installs on Windows) the build of
conpty/conpty_console_list/winpty-agent/winpty fails.
Fix: new scripts/fix-spectre.js (idempotent) flips
SpectreMitigation to 'false' in both .gyp files before the rebuild, so
the generator emits <SpectreMitigation>false</SpectreMitigation> and
MSBuild skips /Qspectre and the existence check. package.json postinstall
now runs the script first:
"postinstall": "node scripts/fix-spectre.js && electron-rebuild -f -w node-pty"
Verified: clean `rm -rf node_modules && npm install` succeeds
("Rebuild Complete", 0 vulnerabilities) and the built .node binary loads
inside Electron 42 (ABI 146).
2) npm run dev: Electron window opens blank, log says
"Failed to load URL: http://localhost:5173/ with error: ERR_CONNECTION_REFUSED"
Cause: Vite dev server binds to 'localhost', which since Node >= 17
resolves to [::1] (IPv6) first — netstat showed the listener on
[::1]:5173 only. The Electron renderer connects via 127.0.0.1 (IPv4),
where nothing listens → connection refused → blank window.
Fix: electron.vite.config.ts renderer section now pins the dev server to
the IPv4 loopback:
renderer: { server: { host: '127.0.0.1' } }
electron-vite then sets ELECTRON_RENDERER_URL to http://127.0.0.1:5173/.
Verified: dev log is error-free, netstat shows 127.0.0.1:5173 LISTENING,
and the window renders the full Kadr UI (media panel, preview,
properties, timeline V2/V1/A1).
3) Docs: README.md / README.en.md — "Windows" notes under Getting started
explaining both failure modes, the repo-side workaround, and the
alternative manual fix (install the "MSVC v143 – C++ x64/x86
Spectre-mitigated libs" component via Visual Studio Installer).
4) package-lock.json: regenerated by the clean npm install used to verify
fix 1 — npm re-resolved 104 transitive packages to their newest
versions within the ^-ranges declared in package.json (e.g. electron
42.4.0 → 42.9.2, rollup 4.61.1 → 4.62.4, esbuild 0.28.1 → 0.28.2,
@electron/rebuild 4.0.4 → 4.2.0).
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@KorolevOl