Friday, December 21, 2018

How to exit in Node.js




What is the command that is used to exit? (i.e terminate the Node.js process)


Answer



Call the global process object's exit method:



process.exit()


From the docs:





process.exit([code])



Ends the process with the specified code. If omitted, exit uses the 'success' code 0.



To exit with a 'failure' code:



process.exit(1);



The shell that executed node should see the exit code as 1.



No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...