bjskistad bjskistad - 1 month ago 5
Node.js Question

What's the difference between abort() and exit() in Node?

I noticed that both

process.exit()
and
process.abort()
both stop a script. What are the differences between the two besides that one logs
Aborted
?

Answer

process.abort() stops the process immediately.

process.exit([exitCode]) method instructs Node.js to terminate the process as quickly as possible. You can also specify an exit code.

For exit codes:

  • 0 means the process was exited successfully.
  • 1 means it ended abnormally.
  • When omitted, 0 is the default value.
Comments