The process Object

process is a global EventEmitter describing the running program: who started it, with what arguments, how much memory it holds, how it should finish. Import it as node:process: the explicit import survives bundling.

Interrogating the current processJavaScript
import process from 'node:process';
console.log(`${process.version} ${process.platform}/${process.arch}  pid=${process.pid}`);
console.log(`args  : ${JSON.stringify(process.argv.slice(2))}`);
const m = process.memoryUsage(), mb = (n) => (n / 1048576).toFixed(1).padStart(6);
console.log(`memory: rss${mb(m.rss)} heapTotal${mb(m.heapTotal)} heapUsed${mb(m.heapUsed)}`);
process.exitCode = 3;
process.on('exit', (code) => console.log(`exit  : leaving with code ${code}`));
Output
v25.8.0 win32/x64  pid=2000
args  : ["--verbose","report.json"]
memory: rss  35.8 heapTotal   5.6 heapUsed   4.8
exit  : leaving with code 3

argv[0] is the Node binary and argv[1] the entry script, so real arguments start at index 2. memoryUsage() reports rss — everything the OS has mapped for you, V8 86,723 's own code included — plus heapTotal, heapUsed, external and arrayBuffers. An empty Node process costs about 36 MB of RSS, the number to budget containers with.

Set process.exitCode rather than call process.exit(): assignment lets the event loop drain — pending stdout writes, open handles, finally blocks — where process.exit() truncates all of it and on a piped stdout can lose your last lines.