Skip to content

/codes/nodejs/node-exit-codes

Node.js exit codes: 1, 9, 13, 124 and 128+ explained

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash) · v24.20.0updated 2026-10-20
tool
Node.js
versions
Node.js 20+
os
any

Node.js exits with 0 when no asynchronous work is left, and with 1 when an exception is never caught. Other codes are rarer: 9 for an invalid command-line option, 13 for a top-level await that never settles, and 128 plus the signal number when a signal kills the process.

Exit code table

CodeNameWhen
0SuccessNo more pending work, or process.exit() / process.exitCode = 0
1Uncaught Fatal ExceptionAn exception was not caught by any handler
3Internal JavaScript Parse ErrorBootstrapping code failed to parse (Node.js development only)
4Internal JavaScript Evaluation FailureBootstrapping code did not return a function
5Fatal ErrorUnrecoverable V8 error, printed with FATAL ERROR (for example out of memory)
6Non-function Internal Exception HandlerThe internal fatal exception handler is not a function
7Internal Exception Handler Run-Time FailureAn 'uncaughtException' handler itself threw
9Invalid ArgumentUnknown option, or an option without its value
10Internal JavaScript Run-Time FailureBootstrapping function threw
12Invalid Debug Argument--inspect port invalid or unavailable
13Unsettled Top-Level AwaitA top-level await waits on a promise that never settles
14Snapshot FailureBuilding a V8 startup snapshot failed
124Process Timeout--process-timeout elapsed (Node.js 26.11+)
>128Signal ExitsKilled by a fatal signal: 128 + signal number (137 = SIGKILL, 143 = SIGTERM)

Codes 2 and 8 are unused (2 is reserved by shells for builtin misuse; 8 was used by old Node.js versions).

See them happen

bash
node -e "throw new Error('boom')" 2>/dev/null; echo "uncaught exception -> $?"
node --not-a-real-flag 2>/dev/null; echo "invalid argument -> $?"
node --input-type=module -e "await new Promise(() => {})" 2>/dev/null; echo "unsettled top-level await -> $?"
node -e "process.exitCode = 42"; echo "process.exitCode = 42 -> $?"

Output

uncaught exception -> 1
invalid argument -> 9
unsettled top-level await -> 13
process.exitCode = 42 -> 42

Set your own exit code

Prefer process.exitCode = n over process.exit(n): it lets pending output and asynchronous work finish before the process ends.

Sources