Skip to content

Cloudflare Workers Builds fails with Could not detect a directory containing static files #7

Description

@NeumoNeumo

Hi, when deploying a repo based on cfnewup through Cloudflare Workers Builds / Git integration, the deployment fails with Wrangler 4.x.

Reproduction

Cloudflare build settings:

Build command: None
Deploy command: npx wrangler deploy
Root directory: /

The repo contains _worker.js.

The deployment reaches Wrangler and then fails:

Executing user deploy command: npx wrangler deploy

npm warn exec The following package was not found and will be installed: wrangler@4.128.0

⛅️ wrangler 4.128.0
────────────────────

✘ [ERROR] Could not detect a directory containing static files (e.g. html, css and js) for the project

Failed: error occurred while running deploy command

Possible Cause

_worker.js is recognized specially by Cloudflare Pages, but wrangler deploy for a normal Worker needs a Worker entrypoint to be specified.

The current wrangler.toml does not appear to declare _worker.js as main, so current Wrangler tries project/static asset auto-detection instead of treating _worker.js as the Worker entrypoint.

Suggested fix

Declare _worker.js explicitly in wrangler.toml:

main = "_worker.js"
compatibility_date = "2026-01-20"

Alternatively, the deployment command would need to specify the entrypoint explicitly:

npx wrangler deploy ./_worker.js

I think adding main = "_worker.js" upstream is preferable, since then Git-connected Cloudflare Workers deployments work with the standard:

npx wrangler deploy

My current edition that works: https://github.com/NeumoNeumo/cfpau/tree/main

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions