退出代码
¥Exit codes
当没有更多异步操作挂起时,Node.js 通常会以 0
状态代码退出。在其他情况下使用以下状态代码:
¥Node.js will normally exit with a 0
status code when no more async
operations are pending. The following status codes are used in other
cases:
-
1
未捕获的致命异常:有一个未捕获的异常,它没有被域或'uncaughtException'
事件处理程序处理。¥
1
Uncaught Fatal Exception: There was an uncaught exception, and it was not handled by a domain or an'uncaughtException'
event handler. -
2
:未使用(由 Bash 预留用于内置误用)¥
2
: Unused (reserved by Bash for builtin misuse) -
3
内部 JavaScript 解析错误:Node.js 引导过程中内部的 JavaScript 源代码导致解析错误。这是极其罕见的,通常只能在 Node.js 本身的开发过程中发生。¥
3
Internal JavaScript Parse Error: The JavaScript source code internal in the Node.js bootstrapping process caused a parse error. This is extremely rare, and generally can only happen during development of Node.js itself. -
4
内部 JavaScript 评估失败:Node.js 引导过程内部的 JavaScript 源代码在评估时未能返回函数值。这是极其罕见的,通常只能在 Node.js 本身的开发过程中发生。¥
4
Internal JavaScript Evaluation Failure: The JavaScript source code internal in the Node.js bootstrapping process failed to return a function value when evaluated. This is extremely rare, and generally can only happen during development of Node.js itself. -
5
致命错误:V8 中有一个不可恢复的致命错误。通常将打印带有前缀FATAL ERROR
的消息到标准错误。¥
5
Fatal Error: There was a fatal unrecoverable error in V8. Typically a message will be printed to stderr with the prefixFATAL ERROR
. -
6
非函数内部异常处理程序:有一个未捕获的异常,但内部致命异常处理函数不知何故设置为非函数,无法调用。¥
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
内部异常处理程序运行时失败:有一个未捕获的异常,内部致命异常处理函数本身在尝试处理它时抛出了一个错误。例如,如果'uncaughtException'
或domain.on('error')
句柄抛出错误,就会发生这种情况。¥
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. This can happen, for example, if an'uncaughtException'
ordomain.on('error')
handler throws an error. -
8
:未使用。在以前版本的 Node.js 中,退出码 8 有时表示未捕获的异常。¥
8
: Unused. In previous versions of Node.js, exit code 8 sometimes indicated an uncaught exception. -
9
无效的参数:指定了未知选项,或者提供了需要值的选项但未提供值。¥
9
Invalid Argument: Either an unknown option was specified, or an option requiring a value was provided without a value. -
10
内部 JavaScript 运行时故障:调用引导函数时,Node.js 引导过程内部的 JavaScript 源代码抛出错误。这是极其罕见的,通常只能在 Node.js 本身的开发过程中发生。¥
10
Internal JavaScript Run-Time Failure: The JavaScript source code internal in the Node.js bootstrapping process threw an error when the bootstrapping function was called. This is extremely rare, and generally can only happen during development of Node.js itself. -
12
无效的调试参数:已设置--inspect
和/或--inspect-brk
选项,但选择的端口号无效或不可用。¥
12
Invalid Debug Argument: The--inspect
and/or--inspect-brk
options were set, but the port number chosen was invalid or unavailable. -
13
未完成的顶层等待:await
在顶层代码的函数外部使用,但传递的Promise
从未解析。¥
13
Unfinished Top-Level Await:await
was used outside of a function in the top-level code, but the passedPromise
never resolved. -
14
快照失败:Node.js 开始构建 V8 启动快照,但由于未满足应用状态的某些要求而失败。¥
14
Snapshot Failure: Node.js was started to build a V8 startup snapshot and it failed because certain requirements of the state of the application were not met. -
>128
信号退出:如果 Node.js 收到SIGKILL
或SIGHUP
等致命信号,则其退出代码将为128
加上信号代码的值。这是标准的 POSIX 实践,因为退出码被定义为 7 位整数,并且信号退出设置高位,然后包含信号代码的值。例如,信号SIGABRT
的值是6
,因此预期的退出码将是128
+6
或134
。¥
>128
Signal Exits: If Node.js receives a fatal signal such asSIGKILL
orSIGHUP
, then its exit code will be128
plus the value of the signal code. This is a standard POSIX 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. For example, signalSIGABRT
has value6
, so the expected exit code will be128
+6
, or134
.