fix(dev-launcher): make npm run dev work on Windows#118
Open
Fronut wants to merge 1 commit into
Open
Conversation
On Windows the npm executable is a npm.cmd shim. `npm run dev` (which runs scripts/dev-launcher.mjs) crashed immediately with `spawn npm ENOENT`, and switching to the `npm.cmd` name alone then failed with `spawn EINVAL` because recent Node.js releases refuse to spawn .cmd/.bat files without a shell (hardening from CVE-2024-27980). Use `npm.cmd` plus `shell: true` on win32 and keep the plain, shell-free spawn on macOS/Linux. The spawn arguments are fixed literals with no user input, so enabling the shell carries no injection risk. This makes `npm run dev` work out of the box on Windows.
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.
Summary
npm run devfails immediately on Windows becausescripts/dev-launcher.mjsspawns
npmwithout a shell. This PR makes the launcher cross-platform so thedocumented "From source (for developers)" quick-start works out of the box on
Windows, while leaving the macOS/Linux behavior unchanged.
Problem
On a fresh clone, following the README quick-start (
npm installthennpm run dev) on Windows produces:Root cause:
npmexecutable is anpm.cmdshim.child_process.spawn('npm', ...)without a shell cannot resolve it, so it throws
ENOENT.npm.cmdname is not enough: recent Node.js releasesrefuse to spawn
.cmd/.batfiles without a shell and throwspawn EINVAL(a security hardening change related to CVE-2024-27980).
Fix
In
scripts/dev-launcher.mjs, onwin32only:npm.cmdas the command, andshell: true.macOS/Linux keep the original plain, shell-free
spawn('npm', ...).The spawn arguments here are fixed string literals (
--workspace,ui,run,dev:concurrent) with no user input, so enabling the shell on Windows carriesno command-injection risk.
Testing
Verified on Windows (PowerShell, Node.js v22.14.0, npm 10.9.2):
npm run devnow boots all three processes successfully:http://localhost:5173(HTTP 200)http://localhost:3001(HTTP 200, "PilotDeck Server - Ready")ws://127.0.0.1:18789/ws(listening)ENOENT/EINVALin stderr.macOS/Linux code path is unchanged (still plain
spawn('npm', ...)with no shell).Scope
This PR intentionally fixes only the developer quick-start entry point
(
dev-launcher.mjs), which is the one blocker that preventsnpm run devfromstarting at all on Windows. Other
spawn('npm'|'npx', ...)call sites inruntime/optional feature paths are out of scope here and can be addressed
separately if desired.