Skip to content
Latchkey

Wrangler Pages "Output directory does not exist" in CI

Wrangler could not find the directory you asked it to deploy. In CI this almost always means the build step did not run, ran in a different working directory, or output to a different folder than the one you passed.

What this error means

A wrangler pages deploy dist step fails with "The directory you specified does not exist" even though it works locally after a manual build.

wrangler
✘ [ERROR] The directory you specified does not exist:
  /home/runner/work/app/app/dist

Common causes

The build step did not run first

The workflow deploys before (or without) the build, so the output folder does not exist yet.

The output path does not match the build config

The framework builds to build/ or .output/public but the deploy command passes dist, so the path is empty or absent.

How to fix it

Build before deploy in the same job

  1. Run the build step first so the output directory is produced.
  2. Pass the exact folder your build writes to.
  3. Keep both steps in one job so the artifact is present.
.github/workflows/ci.yml
- run: npm ci && npm run build
- run: npx wrangler pages deploy dist --project-name my-site
  env:
    CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
    CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}

Match the deploy path to the build output

Confirm the framework output directory (dist, build, .output/public) and pass that exact path to deploy.

How to prevent it

  • Always run the build in the same job before the Pages deploy.
  • Pass the exact output directory your framework produces.
  • Fail fast if the directory is empty to catch a broken build.

Frequently asked questions

What causes ""directory does not exist""?
The workflow deploys before (or without) the build, so the output folder does not exist yet.
How do I fix "directory does not exist"?
Build before deploy in the same job

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card