Node.js process.exit() Method Last Updated : 24 Dec, 2021 Comments Improve Suggest changes Like Article Like Report The process.exit() method is used to end the process which is running at the same time with an exit code in NodeJS. Syntax: process.exit( code ) Parameter: This function accepts single parameter as mentioned above and described below: Code: It can be either 0 or 1. 0 means end the process without any kind of failure and 1 means end the process with some failure. Return value: It does not return any value. As it is the predefined module, so we don't have to install it in our directory. How to implement in code? Create a file with name index.jsCreate a variable with the name process and require the 'process' module in it.Create an infinite loop to check the functionality of .exit(). Case 1: Without using process.exit() method: index.js // Importing process module var process = require('process'); var a = 0; // Infinite loop while (a == 0) { // Printing statement console.log('GeeksforGeeks'); } Run index.js file using below command: node index.js Output: In the above code, we have created an infinite loop that prints GeeksForGeeks until we have stopped the program manually. Case-II: Using process.exit() method: index.js // Importing process module var process = require('process'); var a = 0; // Infinite loop while (a == 0) { // Printing statement console.log('GeeksForGeeks'); // Terminate the entire process process.exit(0); } Run index.js file using below command: node index.js Output: In the above code, we have used the same code as CASE-I but the only difference is we have used process.exit() function that automatically stops the NodeJS program when there is some problem with the code. In this case, the code prints GeeksForGeeks only for a single time. Reference: https://nodejs.org/api/process.html#process_process_exit_code Comment More infoAdvertise with us Next Article Node.js process.exit() Method R rahulmahajann Follow Improve Article Tags : Web Technologies Node.js Node.js-Methods Node.js-process-module Similar Reads Node.js process.getuid() Method The process.getuid() method is an inbuilt application programming interface of the process module which is used to get the numerical user identity of the Node.js process. Syntax: process.getuid() Parameters: This method does not accept any parameters. Return Value: This method returns an integer val 1 min read Node.js process.getgid() Method The process.getgid() method is an inbuilt application programming interface of the process module which is used to get the numerical group identity of the Node.js process. Syntax: process.getgid() Parameters: This method does not accept any parameters. Return Value: It returns an object specifying t 1 min read Node.js process.geteuid() Method The process.geteuid() method is an inbuilt application programming interface of the process module which is used to get the numerical effective user identity of the Node.js process. Syntax: process.geteuid() Parameters: This method does not accept any parameters. Return Value: This method returns an 2 min read Node.js process.getegid() Method The process.getegid() method is an inbuilt application programming interface of the process module which is used to get the numerical effective group identity of the Node.js process. Syntax: process.getegid() Parameters: This method does not accept any parameters. Return Value: It returns an object 2 min read Node.js process.abort() Method The process.abort() property is an inbuilt application programming interface of the process module which is used to abort a running NodeJS process immediately. It also generates a core file. Syntax: process.abort() Parameter: This function does not accept any parameter. Return Type: It has a void re 2 min read Like