Node.js process.exitCode Property Last Updated : 04 Apr, 2023 Comments Improve Suggest changes Like Article Like Report There are two ways that are generally used to terminate a Node.js program which is using process.exit() or process.exitCode variable. In this post, we have discussed the process. exit code variable. It is an integer that represents the code passed to the process.exit() function or when the process exits on its own. It allows the Node.js program to exit naturally and avoids the Node program to do additional work around event loop scheduling, and it is much safer than passing exit code to process.exit(). Syntax: process.exitCode = value Here value means exit code value. Example 1: One way is to pass the exit code value to process.exit() function. Exit code 1 is used when unhandled fatal exceptions occur that were not handled whereas Exit code 0 is used to terminate when no more async operations are happening. JavaScript const express = require('express') const app = express() let a = 10; let b = 20; if (a == 10) { console.log(a) process.exitCode(1); } console.log(b); app.listen(3000, () => console.log('Server ready')) Output: Example 2: Another way is to set process.exitCode value which will allow the Node.js program to exit on its own without leaving further calls for the future. JavaScript const express = require('express') const app = express() let a = 10; let b = 20; if (a == 10) { console.log(a) process.exitCode = 0; } console.log(b); app.listen(3000, () => console.log('Server ready')) Output: Comment More infoAdvertise with us Next Article Node.js process.exitCode Property N naman9071 Follow Improve Article Tags : Web Technologies Node.js Node.js-process-module NodeJS-Process Similar Reads Node.js process.execArgv Property The process.execArgv property is an inbuilt application programming interface of the process module which is used to get the node.js specific command-line options passed to the node.js process during launch. Syntax: process.execArgv Return Value: This property returns an array string containing the 2 min read Node.js process.execPath Property The process.execPath property is an inbuilt application programming interface of the process module which is used to get the absolute pathname of the node.js executable which started the node.js process.Syntax:  process.execPath Return Value: This property returns a string signifies the absolute pa 1 min read Node.js process.env Property In Node.js, the process.env property is an essential part of the runtime environment that provides access to environment variables. These variables are key-value pairs that can influence the behaviour of your Node.js application, making it easier to configure and manage different settings across dev 5 min read Node.js process.connected Property The process.connected property is an inbuilt property of the process module which is used by the child process to check if it is connected to the parent process or not. Syntax: process.connectedReturn Value: If the process was spawned from another process then the process.connected property will re 2 min read Node.js process.config Property The process.config property is an inbuilt application programming interface of the process module which is used to get the JavaScript representation of the configure options that are used to compile the current node.js code.Syntax:  process.config Return Value: This property returns an object conta 2 min read Like