[BUG] npm.ps1
hangs indefinitely when invoked via Node.js spawn({ shell: true })
on Windows
#8259
Closed
2 tasks done
Labels
Bug
thing that needs fixing
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
When using Node.js's
child_process.spawn
function with theshell: true
option on Windows to executenpm.ps1 --version
, the spawned process prints the correct npm version to stdout but never terminates or triggers theclose
event on theChildProcess
object. The parent Node.js script hangs indefinitely waiting for the process to close.In contrast, executing
npm.cmd --version
using the exact samespawn
call works as expected: the version is printed, and theclose
event is emitted shortly after.This suggests an issue specifically with how
npm.ps1
behaves or interacts with the shell environment (cmd.exe
typically, whenshell: true
is used) when invoked indirectly, potentially related to process lifetime management or stream handling within the PowerShell script or the intermediatepowershell.exe
process.Expected Behavior
Both
spawn
calls should complete successfully. The output should look something like this, and the parent Node.js script should exit shortly after the secondclose
event:Steps To Reproduce
test-spawn.js
:node test-spawn.js
Observed Behavior:
The script produces output similar to this:
Environment
The text was updated successfully, but these errors were encountered: