node.js退出命令
When fatal error happened, we’d like to kill the program. How to exit the program in Node.js?
当发生致命错误时 ,我们想终止该程序。 如何退出Node.js中的程序?
You can use:
您可以使用:
process.exit()
Here, “process” is a global process object. exit method ends the process.
在此,“过程”是全局过程对象。 exit方法结束该过程。
process.exit([code])
process.exit([code])
Ends the process with the specified code. If omitted, exit uses the
‘success’ code 0.用指定的代码结束进程。 如果省略,则退出使用
“成功”代码0。To exit with a ‘failure’ code:
要以“失败”代码退出:
process.exit(1);
process.exit(1);
The shell that executed Node.js should see the exit code as 1.
执行Node.js的外壳应该将退出代码显示为1。
翻译自: https://www.systutorials.com/how-to-exit-the-program-in-node-js/
node.js退出命令