Is there an existing issue for this?
Current Behavior
2025-04-03T00_27_13_487Z-debug-0.log
This is caused by the spawnWithShell function expecting the environment variable ComSpec to be defined (usually cmd.exe on Windows). However, in some Windows environments, ComSpec might be undefined.

Actual behavior:
Fails with ERR_INVALID_ARG_TYPE.
Proposed solution:
Modify the spawnWithShell function as follows:
if (command === true) {
command = process.platform === 'win32'
? (process.env.ComSpec || 'C:\\Windows\\System32\\cmd.exe')
: 'sh'
}
Expected Behavior
It should default to C:\Windows\System32\cmd.exe if ComSpec is undefined, allowing the command to succeed.
Steps To Reproduce
- On Windows, ensure the environment variable
ComSpec is unset or missing.
- Run an npm command like
npm start that uses opts.shell = true internally.
- Observe the above error.
Environment
- Node: v22.14.0 (managed by nvm-windows)
- npm: v11.2.0
- OS: Windows 10
- promise-spawn version: (version used by npm internally)
- platform: LG gram
Is there an existing issue for this?
Current Behavior
2025-04-03T00_27_13_487Z-debug-0.log
This is caused by the
spawnWithShellfunction expecting the environment variableComSpecto be defined (usuallycmd.exeon Windows). However, in some Windows environments,ComSpecmight be undefined.Actual behavior:
Fails with
ERR_INVALID_ARG_TYPE.Proposed solution:
Modify the
spawnWithShellfunction as follows:Expected Behavior
It should default to
C:\Windows\System32\cmd.exeifComSpecis undefined, allowing the command to succeed.Steps To Reproduce
ComSpecis unset or missing.npm startthat usesopts.shell = trueinternally.Environment