Exit from a node script
Snippet
kitt decided around 22:19 on 5 July 2016 to publish this:
Node scripts wait for the last event before exiting. Use the global process object's exit method to exit cleanly.
Ends the process with the specified code. If omitted, exit uses the 'success' code 0.
Use a positive (read: non-zero) exit code to indicate error. 1 is reasonable. The shell that executed node should see the exit code as 1.
// default to 0, success process.exit() // actual call process.exit([code]) /* to exit with a 'failure' code: */ process.exit(1);
Add new comment