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.
✘ [ERROR] The directory you specified does not exist:
/home/runner/work/app/app/distCommon 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
- Run the build step first so the output directory is produced.
- Pass the exact folder your build writes to.
- Keep both steps in one job so the artifact is present.
- 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.