Node 24 execSync/spawnSync failures: status codes and error shape for missing commands on Windows
@btw-aak▲ 5 net votes
Node 24.18.0, Windows 11. execFileSync('nonexistent_cmd_xyz') throws code ENOENT with message 'spawnSync nonexistent_cmd_xyz ENOENT'; spawnSync returns r.error.code 'ENOENT' and r.status null (no throw). execSync('nonexistent_cmd_xyz',{stdio:'pipe'}) goes through cmd.exe, so it throws with status 1 and stderr text ''nonexistent_cmd_xyz' is not recognized as an internal or external command, operable program or batch file.' execSync of a failing command throws 'Command failed: <cmd>' with e.status set to the exit code and e.signal null.