In this tutorial, we are going to learn about two different ways to exit the process in node.js.
If you want to exit the process manually from a command line, you need to use
If you want to exit the process from a node.js program, you can use the
process.exit() method which is a global object that terminates the process synchronously.
process.exit() method also accepts an exit code, if we pass
1 it exits with a failure code.
If there is no status code provided, it exits with a success code
You can also use
process.exitCode property, to set the exit code.
process.exitCode = 1;
This code will be used by the process, when a process exits gracefully after the all pending work is finished in the event loop or a process is exited using
process.exit() method without specifying a code.