[BUG] `pnpm run test` fails with `Error: /d: /d: Is a directory` on Windows
Environment
- Platform (select one):
- [*] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version: <!-- output of
claude --version-->
1.0.57 (Claude Code)
- Operating System: <!-- e.g. macOS 14.3, Windows 11, Ubuntu 22.04 -->
Windows 11 Version 24H2
- Terminal: <!-- e.g. iTerm2, Terminal App -->
Windows Termianl
- Node.js
v22.17.1
- pnpm
10.13.1
Bug Description
On Windows systems, when executing pnpm run test from within a Bash-compatible shell (such as Git Bash or MSYS2), the following error is thrown:
Error: /d: /d: Is a directory
This issue appears to be caused by how Bash interprets drive-letter syntax (/d:), mistaking it for a path or command-line flag, leading to misexecution of the script. The issue does not occur when running the same command in Command Prompt (CMD) or PowerShell.
The error can occur even if the test script itself is minimal, such as:
{
"name": "claude-bugs-with-windows",
"version": "0.1.0",
"description": "claude with pnpm in Windows bugs.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
}
}
This suggests the problem lies not within the script contents, but in how pnpm invokes the underlying shell or script runner under Bash on Windows.
Steps to Reproduce
- Create a sample project and initialize with
pnpm:
``bash``
mkdir test-project && cd test-project
pnpm init -y
- Add a dummy test script in
package.json:
``json``
{
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
}
}
- Run the test command:
``bash``
pnpm run test
- Observe the error:
``bash``
Error: /d: /d: Is a directory
Expected behavior
The command pnpm run test should execute the test script successfully in any shell environment, including Git Bash on Windows.
It should behave consistently with CMD or PowerShell.
Actual Behavior
When executed in Git Bash (or similar Bash-compatible environments on Windows), pnpm run test fails with the error:
Error: /d: /d: Is a directory
This indicates that the shell is misinterpreting the drive letter /d: as a malformed path or option, likely due to a discrepancy in how pnpm resolves script paths in Bash vs CMD environments.
Additional Context
- This issue seems specific to Bash-like environments on Windows, such as:
- Git Bash
- MSYS2
- Cygwin
- The error likely arises from how Windows-style drive paths like
/d/or/c/are interpreted by Bash vs Node.js spawn behavior. - This may be related to how
pnpminternally spawns scripts or resolves shell paths when not using native Windows shells. - No such error occurs when using:
cmd.exe- Windows Terminal with PowerShell
- As a workaround, switching to CMD or PowerShell avoids the issue.
If this is a known limitation of cross-shell compatibility, a warning or documentation note may be helpful for developers on Windows using Git Bash.
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗