0

我正在尝试制作一个可以根据命令关闭的 Discord 机器人。昨天我问了另一个与此相关的问题,但没有人回答。所以现在我在想有没有办法从命令行/ .ts 文件中停止 ts-node-dev ?

4

1 回答 1

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

于 2021-11-26T07:05:51.343 回答