node.js - node.js 中的方法 process.exit(1) 和 process.exit(0) 有什么区别?

标签 node.js

在 node.js 应用程序中,我看到了 process.exit(1)process.exit(0) 这两种方法的用法。谁能给我准确的答案?

最佳答案

Node normally exits with a 0 status code when no more async operations are pending. There are other exit codes which are described below:

1 - Uncaught Fatal Exception: There was an uncaught exception, and it was not handled by a domain or an uncaughtException event handler.

2 - Unused: Reserved by Bash for built in misuse.

3 - Internal JavaScript Parse Error: The JavaScript source code internal in Node's bootstrapping process caused a parse error. This is extremely rare, and generally can only happen during the development of Node itself.

4 - Internal JavaScript Evaluation Failure: The JavaScript source code internal in Node's bootstrapping process failed to return a function value when evaluated. This is extremely rare, and generally can only happen during the development of Node itself.

5 - Fatal Error: There was a fatal unrecoverable error in V8. Typically, a message will be printed to stderr with the prefix FATAL ERROR.

6 - Non-function Internal Exception Handler: There was an uncaught exception, but the internal fatal exception handler function was somehow set to a non-function, and could not be called.

7 - Internal Exception Handler Run-Time Failure: There was an uncaught exception, and the internal fatal exception handler function itself threw an error while attempting to handle it.

8 - Unused

9 - Invalid Argument: Either an unknown option was specified, or an option requiring a value was provided without a value.

10 - Internal JavaScript Run-Time Failure: The JavaScript source code internal in Node's bootstrapping process threw an error when the bootstrapping function was called. This is extremely rare, and generally can only happen during the development of Node itself.

11 - Invalid Debug Argument: The --debug and/or --debug-brk options were set, but an invalid port number was chosen

>128 - Signal Exits: If Node receives a fatal signal such as SIGKILL or SIGHUP, then its exit code will be 128 plus the value of the signal code. This is a standard Unix practice, since exit codes are defined to be 7-bit integers, and signal exits set the high-order bit, and then contain the value of the signal code.

来源: https://www.tutorialspoint.com/nodejs/nodejs_process.htm

关于node.js - node.js 中的方法 process.exit(1) 和 process.exit(0) 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43147330/

相关文章:

node.js - 在 Node.js 中更改 JPEG 文件 DPI header

javascript - 未调用 Amazon Alexa 技能回调

node.js - 使用 jenkins 在 EC2 上运行的 pm2 不起作用?

node.js - Node JS 嵌套函数被跳过

javascript - 如何检查用户在 Discord 中是否已经超时?

javascript - 保存 Mongoose 文档时出现版本错误

node.js - SailsJS : Prevent Model. create() 如果它有未声明的属性

javascript - 不允许使用expressjs加载本地资源

ruby-on-rails - 使用 Node 或 ruby 读取非常大的 Excel [XLSX] 的最佳方法

node.js - pipe()后 'finish'上的nodejs空文件