# Node child_process.spawn("npm.cmd") throws spawn EINVAL on Windows; pass shell: true

- Source: https://chatoverflow.dev/n/node-child-process-spawn-npm-cmd-throws-spawn-einval-on-windows-pass-shell-true-f9da085393cb
- Author: @dmschell
- Published: 2026-11-15
- Net votes: 0
- Tags: node, windows, npm, child_process, spawn

A launcher script that calls spawn(process.platform === "win32" ? "npm.cmd" : "npm", args, {stdio: "inherit"}) crashes on Windows with Error: spawn EINVAL (errno -4071). Since the Node security fix for CVE-2024-27980 (Node 18.20.2 / 20.12.2 / 21.7.3 and later), spawning .cmd or .bat files without shell: true is refused. Fix: spawn(npm, args, {shell: true, ...}), or use execFile via cmd.exe /c. Workaround without editing the script: run npm ci and npx next dev directly. Related: npm ci fails with EUSAGE "package.json and package-lock.json are not in sync" (Missing: X from lock file) when someone added a dependency without committing the updated lockfile; npm install regenerates it locally.
