cloudflare / cloudflare/workers-sdk

@cloudflare/vite-plugin dev mode fails to load worker entry with @react-router/dev's vite dev: "Failed to load url ... Does the file exist?" for a file that exists

Open
#14,969 2 comments 0 reactions 0 assignees View on GitHub
package:vite-plugin
Dominant language
TypeScript
Stars
4.5k
Forks
1.5k
Avg merge
3d 8h
Merged PRs (30d)
187

Description

### What versions & operating system are you using?

Windows 11

### Please provide a link to a minimal reproduction

https://github.com/TosinISOGUN/sweep-shopify-app

### Describe the Bug

Versions

@cloudflare/vite-plugin: 1.50.0 (latest at time of report)
@react-router/dev: 7.12.0
wrangler: 4.118.0
Node: v24.16.0
OS: Windows 11
Repro
Minimal setup: the official shopify-app-template-react-router scaffold, migrated to Cloudflare Workers hosting per Cloudflare's own React Router + Workers guide (@cloudflare/vite-plugin added to vite.config.ts, wrangler.json with main: "./workers/app.ts").

Running npx vite dev (or react-router dev, which wraps it) fails immediately at startup:
error when starting dev server:
Error: Failed to load url /workers/app.ts (resolved id: C:/Users/.../workers/app.ts) in virtual:cloudflare/worker-entry. Does the file exist?
at runInRunnerObject (workers/runner-worker/index.js:107:3)
at getWorkerEntryExportTypes (workers/runner-worker/index.js:252:24)

The file genuinely exists at the resolved path and builds/deploys correctly (vite build + wrangler deploy both succeed and the app runs correctly in production). Standalone wrangler dev (without the Vite plugin, against the built output) also works fine. Only the Vite-plugin-driven dev-mode module-runner path fails.

Investigation so far

Confirmed NOT a path-resolution problem: the "resolved id" shown in the error is the fully correct absolute path to the real file.
Traced into Vite core (chunks/dep-*.js, the loadAndTransform function): the failure happens because no plugin's load hook returns content for this id, and Vite's built-in filesystem-read fallback also produces no content, triggering the generic "Does the file exist?" message despite the file being real.
This appears specific to the Cloudflare plugin's custom "workerd" Vite Environment during the getWorkerEntryExportTypes() startup call, in combination with @react-router/dev's vite dev command specifically.
Expected
vite dev starts successfully and the worker entry loads, matching the working vite build / wrangler deploy path.

Note: the repo above is currently private. Happy to make it public or grant access if that would help — the full repro steps above should be enough to reproduce from a fresh scaffold in the meantime.

### Please provide any relevant error logs

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the Cloudflare Vite plugin's workerd Environment and the getWorkerEntryExportTypes() startup path; the reported failure is in virtual:cloudflare/worker-entry while loading workers/app.ts. Reproduce with npx vite dev using the linked scaffold and compare it with the working vite build and wrangler deploy paths. Done means the worker entry loads and vite dev starts successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
build-system, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.