node js quit
Node JS Quit
Have you ever been in a situation where your Node JS application is running and you want to stop it? There are two ways you can quit a Node JS application.
Method 1: Using CTRL + C
The simplest way to quit a Node JS application is by using CTRL + C. When you press CTRL + C, the Node JS process will be terminated, and the terminal will be free again.
Method 2: Using process.exit()
If for some reason, you cannot use CTRL + C to quit your Node JS application, you can use the process.exit()
method. This method will terminate the Node JS process and exit the application.
process.exit();
The process.exit()
method can also take an exit code as an argument. The exit code is a number that represents the status of the application. A successful exit will have an exit code of 0, while an unsuccessful exit will have a non-zero exit code.
process.exit(1);
It is important to note that using process.exit()
is not recommended in most cases. It is better to let the Node JS process exit naturally.