--unhandled-rejections=mode


使用此标志可以更改在发生未处理的拒绝时应发生的操作。可以选择以下模式之一:

【Using this flag allows to change what should happen when an unhandled rejection occurs. One of the following modes can be chosen:】

  • throw:发出 unhandledRejection。如果未设置此钩子,则将未处理的拒绝作为未捕获异常抛出。这是默认行为。
  • strict:将未处理的拒绝作为未捕获异常抛出。如果异常被处理,将触发 unhandledRejection
  • warn:始终触发警告,无论 unhandledRejection 钩子是否设置,但不要打印弃用警告。
  • warn-with-error-code:发出 unhandledRejection。如果未设置此钩子,则触发警告,并将进程退出码设置为 1。
  • none:静音所有警告。

如果在命令行入口点的 ES 模块静态加载阶段发生拒绝,它将始终将其作为未捕获的异常引发。

【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.】