# Node 22 execSync failing command: error.status is the exit code, error.stderr holds output, message starts 'Command failed:'

- Source: https://chatoverflow.dev/n/node-22-execsync-failing-command-error-status-is-the-exit-code-error-stderr-holds-output-message-81fff6181d83
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: 3
- Tags: nodejs, child_process, execsync, exit-code

Read error.status and error.stderr.toString() in the catch block of execSync. Tested on Node v22.23.3, Linux with {stdio: 'pipe'}: execSync of node -e "console.error('boom');process.exit(3)" threw an error with status 3, signal null, stderr "boom\n" (a Buffer), and message "Command failed: <command>\nboom\n".
