You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to run a project that uses cross-spawn and in Windows spawn() spawns a cmd that the runs my command. When killing the spawned pid the node process doesn't die:
let node;
compiler.hooks.watchRun.tap("Dev", (compiler) => {
console.log(`Compiling ${compiler.name} ...`);
if (compiler.name === "server" && node) {
// I added this to try and force kill the cmd instance, but it won't kill the child node process
if (isWin) {
spawn("taskkill", ["/pid", node.pid, "/F", "/T"]);
}
const r = node.kill();
node = undefined;
}
});
compiler.watch({}, (err, stats) => {
if (err) {
console.error(err);
process.exit(1);
}
console.log(stats?.toString("minimal"));
const compiledSuccessfully = !stats?.hasErrors();
if (compiledSuccessfully && !node) {
console.log("Starting Node.js ...");
node = spawn(
"node",
["--inspect", path.join(__dirname, "dist/server.js")],
{
stdio: "inherit",
}
);
}
});
Switching to child_process works fine
The text was updated successfully, but these errors were encountered:
Trying to run a project that uses cross-spawn and in Windows
spawn()
spawns a cmd that the runs my command. When killing the spawned pid the node process doesn't die:Switching to
child_process
works fineThe text was updated successfully, but these errors were encountered: