I'm trying to make a Discord bot that can shut down on command. Yesterday I asked another question related to this but no one answered. So now I'm thinking is there any way to stop ts-node-dev from command line / .ts file?
Asked
Active
Viewed 1,158 times
1 Answers
0
Have you tried process.exit(1)? It works in js. I think you need to install @types/node
for ts?
Alternatively you can use a bit of a whacky method: You can try launching ts-node with pm2 or nodemon and in order to kill your bot try executing cli command like
exec("killall nodemon", (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
console.log(`stdout: ${stdout}`);
});
I hope it helps

gettinggud
- 13
- 4
-
Yes I did try process.exit. It didn't work because it tried to exit node.js not ts-node – ProGamer2711 Nov 26 '21 at 09:02
-
Hello, I'm still trying to pull it off with pm2 but for now I see an error about using TypeScript. Do you know how I can do it? The error: SyntaxError: Unexpected token ':' – ProGamer2711 Nov 26 '21 at 11:45