Exit from a node script


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
// actual call
/* to exit with a 'failure' code: */

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.