build error
exit code 9009
software development
troubleshooting
programming error

What does "exited with code 9009" mean in a build?

Codemia Knowledge Hub ·

Exit code 9009 means Windows cmd.exe could not find the program or command you tried to run. It is the Windows equivalent of "command not found" on Unix. The fix is almost always one of three things: the tool is not installed, its directory is not in PATH, or the build script has a typo in the command name.

It shows up most often in Visual Studio build events, MSBuild scripts, npm scripts on Windows, and CI pipelines on Windows runners. The number 9009 (hex 0x2331) is specific to cmd.exe and does not appear on Linux or macOS.

What the 9009 error looks like

When cmd.exe cannot find a matching executable, internal command, batch file or script, it returns 9009, analogous to exit code 127 on Unix shells. The output typically looks like:

 
'some-tool' is not recognized as an internal or external command,
operable program or batch file.
error MSB3073: The command "some-tool --version" exited with code 9009.

The first line is the actual diagnostic from cmd.exe. The second is MSBuild (or another build system) reporting the non-zero exit code.

Causes and fixes

1. Tool not installed

The script references a tool that is not installed on this machine, which is common when a project moves between developer machines or onto a CI runner without the same global tools.

batch
REM Build script expects webpack to be available globally
webpack --config webpack.config.js
REM If webpack-cli is not installed globally, this fails with 9009

Fix: install the missing tool. For npm-based tools, prefer local installation over global:

bash
npm install --save-dev webpack webpack-cli
npx webpack --config webpack.config.js

2. Directory not in PATH

The tool is installed but cmd.exe only searches directories listed in PATH.

batch
REM Python is installed at C:\Python311 but PATH does not include it
python --version
REM 'python' is not recognized... exited with code 9009

Fix: add the tool's directory to PATH:

batch
1REM Temporary (current session only)
2set PATH=%PATH%;C:\Python311
3
4REM Permanent (requires new terminal)
5setx PATH "%PATH%;C:\Python311"

Or use the full path in the build script:

batch
C:\Python311\python.exe --version

3. Typo in the command name

A misspelled or wrong executable name gives the same error, often in copy-pasted build scripts:

batch
REM Wrong: "dockr" instead of "docker"
dockr build -t myapp .

4. Missing file extension or call

On Windows, executables need their extension (.exe, .cmd, .bat) unless it is listed in PATHEXT. Some tools, like npm, install as .cmd files, and calling them without the extension from certain contexts can fail:

batch
1REM This may fail in some build event contexts
2npm install
3
4REM This is more reliable
5call npm install

call tells cmd.exe to invoke a batch file and return to the calling script afterward. Without it, cmd.exe transfers control to the batch file and never returns.

5. PowerShell syntax in Visual Studio build events

Pre-build and post-build events run inside cmd.exe by default, not PowerShell, so PowerShell commands fail:

 
1REM Visual Studio Pre-build event
2REM Wrong: PowerShell syntax in a cmd.exe context
3Get-Date > build-timestamp.txt
4
5REM Correct: Use cmd.exe syntax
6echo %DATE% %TIME% > build-timestamp.txt

Debugging exit code 9009 step by step

Step 1: Identify the exact command that failed. The build output usually shows the full command before the error. Copy it.

Step 2: Run it manually in cmd.exe. Test in the same shell the build uses; a command that works in PowerShell may not work in cmd.exe, and vice versa.

batch
cmd.exe /c "the-exact-command --with-args"

If it fails here too, the problem is the command itself, not the build system.

Step 3: Check whether the tool can be found.

batch
where some-tool

where is the Windows equivalent of which. "Could not find files for the given pattern(s)" means the tool is not in PATH.

Step 4: Check PATH.

batch
echo %PATH%

Verify that the tool's directory is listed.

Step 5: Check PATHEXT.

batch
echo %PATHEXT%

The default is .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC. A tool with a non-standard extension may not be found without the explicit extension.

Fixing 9009 in specific build systems

MSBuild / Visual Studio

Use call before batch files and verify PATH:

xml
<PreBuildEvent>
  <Command>call npm install</Command>
</PreBuildEvent>

If the command is optional and the build should continue when it fails, wrap it:

xml
<PreBuildEvent>
  <Command>call npm install || echo "npm install failed but continuing"</Command>
</PreBuildEvent>

Do not reach for || exit 0 or similar without knowing why the command failed; it hides the symptom and leaves the root cause in place.

npm scripts on Windows

npm scripts run through cmd.exe on Windows. Locally installed tools live in node_modules/.bin, which npm adds to PATH during script execution:

json
1{
2  "scripts": {
3    "build": "webpack --mode production",
4    "lint": "eslint src/"
5  }
6}

npm run build works because npm resolves webpack from node_modules/.bin. Running webpack --mode production directly in cmd may fail if webpack is not installed globally.

GitHub Actions on Windows runners

Pipelines on windows-latest hit this error when a tool is not pre-installed:

yaml
1jobs:
2  build:
3    runs-on: windows-latest
4    steps:
5      - uses: actions/checkout@v4
6      - name: Install dependencies
7        run: npm ci
8      - name: Build
9        run: npx webpack --mode production
10        shell: cmd  # Explicitly use cmd.exe

shell: cmd forces cmd.exe. Alternatively, shell: bash on Windows runners gives Unix-like behavior through Git Bash. Install every required tool as part of the pipeline setup.

Exit codes across platforms

ErrorPlatformMeaning
Exit code 9009Windows (cmd.exe)Command not found
Exit code 1Windows (cmd.exe)General error (catch-all)
Exit code 127Linux/macOS (bash/zsh)Command not found
Exit code 126Linux/macOS (bash/zsh)Permission denied (not executable)
Exit code 2Linux/macOS (bash/zsh)Misuse of shell command / syntax error

Preventing 9009 on other machines

  • Do not assume a tool is installed globally everywhere. Use project-local installs (node_modules/.bin, virtual environments) and npx or an equivalent.
  • Avoid absolute paths that exist only on one developer's machine. Use environment variables or relative paths.

Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Basis Lab
No course covers this one yet

Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.

Build my course
Interview Questions practice on Codemia

Over 11,000 interview practice questions for 300+ companies, searchable by company and role.

Browse interview questions