George Bailey George Bailey - 1 year ago 55
Node.js Question

How to exit in Node.js

What is the command that is used to exit?

Answer Source

Call the global process object's exit method:


From the docs:


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 should see the exit code as 1.