Bootstrap FreeKB - Node.js - Stop Halt or Exit
Node.js - Stop Halt or Exit

Updated:   |  Node.js articles

process.exit() can be used to stop, halt, exit the execution of a Node.js script. In this example, Hello will be printed, the script will be exited, meaning World will not be printed.

console.log("Hello")
process.exit()
console.log("World")

 

You can also declare the exit code, such as 0 (OK) or 1 (Fault).

console.log("Hello")
process.exit(0)
console.log("World")

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter f06b34 in the box below so that we can be sure you are a human.