How to close Node.JS in the application?

-1

How do I stop a Node.JS application?

For example, in PHP we have something like this:

exit;

Or:

die('Mensagem.');

Is there any way to stop the Node application like this, without having to use Ctrl + C ?

    
asked by anonymous 02.03.2018 / 19:09

1 answer

1

There are two ways through the object process :

(1) process.abort()

(2) process.exit(codigoDeSaida)

The first aborts the program on time, usually for abnormal things.

The second commands the Node to exit the program "gracefully" with an optional exit code (which may mean an error).

    
02.03.2018 / 19:17