process object
The global object in Node.js that describes the running process and lets you read its environment and arguments, measure its memory, listen for signals and exit.
In more detail
It is an EventEmitter, so process.on("SIGTERM", handler) or process.on("exit", handler) registers listeners. It is available everywhere without an import.
Related terms
- process.env — The object in Node.js that holds the process's environment variables, with every value stored as a string.
- process.exit() — A Node.js function that ends the process at once with the exit code you give, skipping any work still waiting on the event loop.
- beforeExit and exit events — Process events: beforeExit fires when the event loop has run out of work and may schedule more, while exit fires just before the process ends and allows only synchronous code.
- EventEmitter — The Node.js class for objects that emit named events and call registered listener functions, similar to the browser's EventTarget.
Taught in
- Close Phase & Signal Dispatch: Sockets & Teardown — Node.js Internals & Backend Services
- Global Error Trapping: uncaughtException & Exits — Node.js Internals & Backend Services
- Production Hardening: Graceful Shutdown & Docker — Node.js Internals & Backend Services