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
| Code | Name | When |
|---|---|---|
| 0 | Success | No more pending work, or process.exit() / process.exitCode = 0 |
| 1 | Uncaught Fatal Exception | An exception was not caught by any handler |
| 3 | Internal JavaScript Parse Error | Bootstrapping code failed to parse (Node.js development only) |
| 4 | Internal JavaScript Evaluation Failure | Bootstrapping code did not return a function |
| 5 | Fatal Error | Unrecoverable V8 error, printed with FATAL ERROR (for example out of memory) |
| 6 | Non-function Internal Exception Handler | The internal fatal exception handler is not a function |
| 7 | Internal Exception Handler Run-Time Failure | An 'uncaughtException' handler itself threw |
| 9 | Invalid Argument | Unknown option, or an option without its value |
| 10 | Internal JavaScript Run-Time Failure | Bootstrapping function threw |
| 12 | Invalid Debug Argument | --inspect port invalid or unavailable |
| 13 | Unsettled Top-Level Await | A top-level await waits on a promise that never settles |
| 14 | Snapshot Failure | Building a V8 startup snapshot failed |
| 124 | Process Timeout | --process-timeout elapsed (Node.js 26.11+) |
| >128 | Signal Exits | Killed 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
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
Related pages
errors · nodejsError: Cannot find module '…' in Node.jsNode.js throws Cannot find module when require() or import cannot resolve a path or package. Install the package, fix the relative path or add the extension.changes · nodejsNode.js 24 to 26: breaking changes and migrationUpgrading from Node.js 24 to 26: Temporal on by default, V8 14.6, Undici 8, fs.F_OK and SlowBuffer removed, legacy _stream modules gone, native addons rebuilt.config · nodejspackage.json "type": "module": ES modules in Node.jsSetting "type": "module" in package.json makes Node.js load .js files as ES modules: import and export work, require is undefined, and .cjs stays CommonJS.