process.traceProcessWarnings


process.traceProcessWarnings 属性指示当前 Node.js 进程上是否设置了 --trace-warnings 标志。此属性允许以编程方式控制警告的跟踪,从而在运行时启用或禁用警告的堆栈跟踪。

🌐 The process.traceProcessWarnings property indicates whether the --trace-warnings flag is set on the current Node.js process. This property allows programmatic control over the tracing of warnings, enabling or disabling stack traces for warnings at runtime.

// Enable trace warnings
process.traceProcessWarnings = true;

// Emit a warning with a stack trace
process.emitWarning('Warning with stack trace');

// Disable trace warnings
process.traceProcessWarnings = false;