I've seen similar questions here.
One question had an accepted answer of
var spawn = require("child_process").spawn,child; child = spawn("powershell.exe",["c:\\temp\\helloworld.ps1"]); child.stdout.on("data",function(data){ console.log("Powershell Data: " + data); }); child.stderr.on("data",function(data){ console.log("Powershell Errors: " + data); }); child.on("exit",function(){ console.log("Powershell Script finished"); }); child.stdin.end(); //end input I'm on Ubuntu so I changed it to
var spawn = require("child_process").spawn,child; child = spawn("/usr/bin/pwsh",["/srv/webroot/pauseRS.ps1"]); child.stdout.on("data",function(data){ console.log("Powershell Data: " + data); }); child.stderr.on("data",function(data){ console.log("Powershell Errors: " + data); }); child.on("exit",function(){ console.log("Powershell Script finished"); }); child.stdin.end(); //end input I dont get any errors when I run the node package but it doesnt seem to be running the powershell script. Nothing is logged in the console.
The powershell script just runs a web request. When I run the powershell script by itself it runs fine and works as expected. Trying to call the powershell script with node is not giving any errors and not producing any results.
Node 12.21.0
nodeprocess exit? As an side: It looks likechild.stdin.end();isn't required here, since you're not providing stdin input programmatically.