In Node.js, the process.exit()
method is used to exit the current Node.js process with a given exit code. The number
argument passed to process.exit()
represents the exit code that the Node.js process will exit with.
Here are the commonly used exit codes and their meanings:
0
: The process exits successfully without any errors.1
: The process exits due to an uncaught exception.2
: The process exits due to a misconfiguration or missing file.3
: The process exits due to a fatal error.4
: The process exits due to a signal interruption.
You can also use other numbers as exit codes, but these are the most commonly used ones. When the Node.js process exits, the exit code can be retrieved using the process.exitCode
property.