What is process in Node.js?
Answer
process is a global object in Node.js that provides information about, and control over, the current Node.js process. Key properties and methods: process.env — environment variables (e.g., process.env.NODE_ENV, process.env.PORT); process.argv — command-line arguments array (index 0: node path, index 1: script path, index 2+: user args); process.cwd() — current working directory; process.exit(code) — exit the process (0 = success, non-zero = error); process.pid — process ID; process.version — Node.js version string; process.platform — OS platform; process.memoryUsage() — memory usage stats; process.stdin, process.stdout, process.stderr — standard streams; process.on("uncaughtException", handler) — catch unhandled errors (use with care); process.on("SIGTERM", handler) — handle OS signals for graceful shutdown.
Previous
What is the os module in Node.js?
Next
What is the events module and EventEmitter in Node.js?