Windows 11: fix npm install (node-pty MSB8040) and blank dev window (ERR_CONNECTION_REFUSED) - #9
Open
KorolevOl wants to merge 1 commit into
Open
Conversation
…_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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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). Fixes prepared with Hermes Agent (Nous Research) running on qwen3.8:27b.1)
npm installfails: MSBuild error MSB8040 (Spectre mitigation libraries required)Cause:
postinstallrunselectron-rebuild -f -w node-pty, which compiles node-pty from source. node-pty hard-codesSpectreMitigation='Spectre'inbinding.gypanddeps/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 ofconpty/conpty_console_list/winpty-agent/winptyfails.Fix: new
scripts/fix-spectre.js(idempotent) flipsSpectreMitigationto'false'in both.gypfiles before the rebuild, so the generator emits<SpectreMitigation>false</SpectreMitigation>and MSBuild skips/Qspectreand the existence check.package.jsonpostinstall now runs it first:Verified: clean
rm -rf node_modules && npm installsucceeds ("Rebuild Complete", 0 vulnerabilities) and the built.nodebinary loads inside Electron 42 (ABI 146).2)
npm run dev: blank Electron window,ERR_CONNECTION_REFUSEDCause: the Vite dev server binds to
localhost, which since Node ≥ 17 resolves to[::1](IPv6) first —netstatshowed the listener on[::1]:5173only. The Electron renderer connects via127.0.0.1(IPv4), where nothing listens → connection refused → blank window.Fix:
electron.vite.config.tsrenderer section now pins the dev server to the IPv4 loopback:electron-vitethen setsELECTRON_RENDERER_URLtohttp://127.0.0.1:5173/.Verified: dev log is error-free,
netstatshows127.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.jsonRegenerated by the clean
npm installused to verify fix 1 — npm re-resolved 104 transitive packages to their newest versions within the^-ranges already declared inpackage.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 inpackage.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)