--unhandled-rejections=mode
使用此标志可以改变发生未经处理的拒绝时应该发生的事情。 可以选择以下模式之一
throw: 触发unhandledRejection。 如果未设置此钩子,则将未处理的拒绝上升为未捕获的异常。 这是默认值。strict: 上升未处理的拒绝作为未捕获的异常。 如果处理了异常,则触发unhandledRejection。warn: 始终触发警告,无论是否设置了unhandledRejection钩子,但不打印弃用警告。warn-with-error-code: 触发unhandledRejection。 如果未设置此钩子,则触发警告,并将进程退出码设置为 1。none: 静默所有警告。
如果在命令行入口点的 ES 模块静态加载阶段发生拒绝,则它将始终将其作为未捕获的异常引发。
Using this flag allows to change what should happen when an unhandled rejection occurs. One of the following modes can be chosen:
throw: EmitunhandledRejection. If this hook is not set, raise the unhandled rejection as an uncaught exception. This is the default.strict: Raise the unhandled rejection as an uncaught exception. If the exception is handled,unhandledRejectionis emitted.warn: Always trigger a warning, no matter if theunhandledRejectionhook is set or not but do not print the deprecation warning.warn-with-error-code: EmitunhandledRejection. If this hook is not set, trigger a warning, and set the process exit code to 1.none: Silence all warnings.
If a rejection happens during the command line entry point's ES module static loading phase, it will always raise it as an uncaught exception.