preview_start fails with EPERM: uv_cwd on macOS

Resolved 💬 3 comments Opened Mar 13, 2026 by sobradob Closed Mar 13, 2026

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

  1. Navigate to a Next.js project directory
  2. Ensure .claude/launch.json exists with a valid config:

``json
{
"version": "0.0.1",
"configurations": [
{
"name": "dev",
"runtimeExecutable": "npx",
"runtimeArgs": ["next", "dev"],
"port": 3000,
"autoPort": true
}
]
}
``

  1. Use preview_start with name: "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 -la both work)
  • Verified npx is available and functional (which npx, npx --version)
  • Tried using node_modules/.bin/next directly instead of npx — same error
  • The error occurs before any project code runs — Node.js itself cannot call process.cwd() in the spawned subprocess
  • Running npx next dev directly 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.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗