When fatal error happened, we’d like to kill the program. How to exit the program in Node.js?
You can use:
Here, “process” is a global process object. exit method ends the process.
Ends the process with the specified code. If omitted, exit uses the
‘success’ code 0.
To exit with a ‘failure’ code:
The shell that executed Node.js should see the exit code as 1.