process Object (Node.js)
process is a global object in Node.js that gives information about and control over the current Node process. It exposes environment variables, command-line arguments, the standard streams, and lifecycle events like exit.
Node.js
process is your interface to the running program and its environment. process.env holds environment variables (the standard way to pass configuration and secrets), process.argv is the array of command-line arguments, and process.cwd() is the current working directory.
It also controls lifecycle and I/O: process.exit(code) ends the program, process.on('exit'|'SIGINT'|'uncaughtException', ...) hooks into shutdown and errors, and process.stdout/process.stderr/process.stdin are the standard streams (console.log writes to process.stdout).
Other useful members include process.version (Node version), process.platform (the OS), process.memoryUsage(), and process.nextTick() (queue a callback before the next event-loop phase). Reading config from process.env and arguments from process.argv are the two things you reach for most.
Syntax
process.env.NODE_ENV
process.argv
process.exit(0)Examples
JavaScript
console.log("args:", process.argv.slice(2));
console.log("env mode:", process.env.NODE_ENV);
process.on("SIGINT", () => {
console.log("shutting down");
process.exit(0);
});