process.report.writeReport([filename][, err])


  • filename <string> 报告写入的文件名。该路径应为相对路径,将附加到 process.report.directory 指定的目录,或者如果未指定,则附加到 Node.js 进程的当前工作目录。
  • err <Error> 用于报告 JavaScript 堆栈的自定义错误。
  • 返回值:<string> 返回生成报告的文件名。

将诊断报告写入文件。如果未提供 filename,默认文件名将包含日期、时间、进程ID(PID)和序列号。报告的 JavaScript 堆栈跟踪将取自 err(如果存在)。

🌐 Writes a diagnostic report to a file. If filename is not provided, the default filename includes the date, time, PID, and a sequence number. The report's JavaScript stack trace is taken from err, if present.

如果 filename 的值被设置为 'stdout''stderr',报告将分别写入进程的标准输出或标准错误。

🌐 If the value of filename is set to 'stdout' or 'stderr', the report is written to the stdout or stderr of the process respectively.

import { report } from 'node:process';

report.writeReport();const { report } = require('node:process');

report.writeReport();

额外的文档可在 报告文档 中获取。

🌐 Additional documentation is available in the report documentation.