preview_start fails with EPERM: uv_cwd on macOS
Bug Description
preview_start consistently fails with EPERM: operation not permitted, uv_cwd when attempting to start a dev server. The subprocess spawned by the preview tool cannot resolve its working directory, even though the CWD is valid and accessible from the shell.
Environment
- OS: macOS (Darwin 25.2.0)
- Node.js: v22.17.0 (via nvm)
- Claude Code: latest (CLI)
- Shell: zsh
Steps to Reproduce
- Navigate to a Next.js project directory
- Ensure
.claude/launch.jsonexists with a valid config:
``json``
{
"version": "0.0.1",
"configurations": [
{
"name": "dev",
"runtimeExecutable": "npx",
"runtimeArgs": ["next", "dev"],
"port": 3000,
"autoPort": true
}
]
}
- Use
preview_startwithname: "dev"
Expected Behavior
The dev server starts and preview tools become available.
Actual Behavior
The subprocess immediately crashes with:
Error: EPERM: operation not permitted, uv_cwd
at process.wrappedCwd [as cwd] (node:internal/bootstrap/switches/does_own_process_state:142:28)
...
Troubleshooting Done
- Verified CWD exists and is accessible (
pwd,ls -laboth work) - Verified
npxis available and functional (which npx,npx --version) - Tried using
node_modules/.bin/nextdirectly instead ofnpx— same error - The error occurs before any project code runs — Node.js itself cannot call
process.cwd()in the spawned subprocess - Running
npx next devdirectly from the same shell works fine
Analysis
The issue appears to be in how the preview infrastructure spawns child processes. The subprocess inherits a CWD context that is stale or has restricted permissions, even though the parent process's CWD is valid. This is a process-management issue in the preview tool, not a project configuration problem.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗