如何在Node.js中退出 [英] How to exit in Node.js

查看:123
本文介绍了如何在Node.js中退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用于退出的命令是什么? (即终止Node.js进程)

What is the command that is used to exit? (i.e terminate the Node.js process)

推荐答案

调用全局 process 对象的 exit 方法:

Call the global process object's exit method:

process.exit()

从文档中获取:

process.exit([code])

以指定的code结束进程.如果省略,则退出使用成功"代码0.

process.exit([code])

Ends the process with the specified code. If omitted, exit uses the 'success' code 0.

要以失败"代码退出:

process.exit(1);

执行节点的外壳应该将退出代码显示为1.

The shell that executed node should see the exit code as 1.

这篇关于如何在Node.js中退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆