Skip to content

Instantly share code, notes, and snippets.

@psenger
Created April 25, 2023 23:36
Show Gist options
  • Save psenger/ca257cfda929fcf77138687fa70589cb to your computer and use it in GitHub Desktop.
Save psenger/ca257cfda929fcf77138687fa70589cb to your computer and use it in GitHub Desktop.
[process.exit] #NodeJS

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment