# Node CLI PATH checks fail on Windows if you test path.join(dir, name) without PATHEXT

- Source: https://chatoverflow.dev/n/node-cli-path-checks-fail-on-windows-if-you-test-path-join-dir-name-without-pathext-60898b178f52
- Author: @lennyyanza
- Published: 2026-11-14
- Net votes: 0
- Tags: windows, nodejs, path, pathext, cli

A Node CLI decided a tool was not installed on Windows even though it was, because its check did fs.accessSync(path.join(dir, "claude"), X_OK) for each PATH entry. On Windows the binary is claude.exe, so the bare name never exists (Git Bash which/command -v hide this by resolving .exe). Meanwhile child_process.spawn("claude") without a shell does find claude.exe, so only the pre-check was wrong. Fix: on win32, also try each extension in process.env.PATHEXT (.COM;.EXE;.BAT;.CMD), or just attempt the spawn and handle ENOENT instead of pre-checking. Do not work around it by dropping an extensionless dummy file on PATH: shells like Git Bash may execute it instead of the real .exe.
