Fix npm start on Windows: spawn via shell so npx resolves to npx.cmd#3627
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes npm start on Windows by allowing Node’s spawn calls in the Studio startup script to resolve shell commands such as npx.cmd.
Changes:
- Adds
shell: trueto the sharedspawnCommandoptions used for launching Vite and Electron Vite.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fredrikekelund
approved these changes
May 29, 2026
Contributor
fredrikekelund
left a comment
There was a problem hiding this comment.
Works great 👍 Thanks for fixing this, @ivan-ottinger
Collaborator
📊 Performance Test ResultsComparing 32a0ab5 vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
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 free
to 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.
Related issues
How AI was used in this PR
Diagnosed and patched with Claude Code. I reviewed the one-line change and verified it locally on Windows.
Proposed Changes
scripts/start-studio.mjsspawnsnpx vite ...andnpx electron-vite ...with rawchild_process.spawn(...). On Windows,npxisnpx.cmd(a batch file), and Node'sspawnwithoutshell: trueonly resolves real executables — sonpm startimmediately throwsError: spawn npx ENOENTand the dev server never starts. macOS/Linux are unaffected becausenpxis a real binary there.Fix: pass
shell: trueto the defaultspawnoptions insidespawnCommand. The shell resolvesnpx→npx.cmdon Windows and findsnpxthe usual way on macOS/Linux.This was a latent bug in the predecessor
scripts/start-new-ui.mjs(only reachable via the opt-innpm run start:new). #3537 promoted that script to defaultnpm start, turning it into a Windows-wide blocker.Why this is safe on macOS/Linux
'vite','--port','5200', etc.), so there's no shell-quoting risk.stdio: 'inherit'still works through the shell wrapper.SIGINT/SIGTERMhandlers in the script already call.kill()on the child references, so Ctrl+C still works.Caveat (not a regression vs. current state, but worth knowing): with
shell: truethe immediate child is the shell wrapper. If the parent script is killed abruptly, the innervite/electron-vitemay briefly outlive the wrapper until they notice their parent is gone. The script's own SIGINT/SIGTERM handlers cover the normal Ctrl+C path.Testing Instructions
Windows (the regression):
git checkout stu-1761-fix-windows-npm-start-enoentnpm install && npm startStarting @studio/ui dev server on port 5200...followed byVITE vX ready in ... ms, then Electron launches.trunkthe same command throwsError: spawn npx ENOENTand exits with code 1.macOS / Linux (regression check):
npm startfrom this branch should behave identically totrunk— vite on 5200, then Electron.Pre-merge Checklist