Open In App

Node.js process.report.getReport([err]) Function

The process.report.gerReport() is a method of process.report javascript object that helps generate a report of the currently running node.js process.

Syntax:



process.report.getReport([err])

Parameters: It takes an array of Error Object that represents a custom error in the javascript stack

Return Value: It returns a javascript object that represents a report for the running process.



Example 1: In this example, we will simply log the currently running process’s report to the console.

Filename: index.js




const { report } = require('node:process');
console.log(report.getReport());

Command to run:

node index.js

Output:

 

Example 2: In this example, we will print the command line of the running process’s header to the console.

Filename: index.js




const { report } = require('node:process');
console.log(report.getReport().header.commandLine);

Command to run:

node index.js

Output:

 

Reference: https://nodejs.org/api/process.html#processreportgetreporterr

Article Tags :