Skip to content

vinext start runs the Node server for Cloudflare projects and cannot find the Worker build (init advertises it as "Start the built Worker locally with Wrangler") #2966

Description

@james-elicx

Problem

For a Cloudflare project, vinext init presents start:vinext as the way to run the built Worker locally:

pnpm run start:vinext  Start the built Worker locally with Wrangler

but the script it writes is vinext start, which is the Node production server. It never invokes Wrangler, and it looks for build output that a Cloudflare build does not produce, so it fails immediately after a successful build:

$ vinext build
✓ built in 9.27s

$ vinext start
[vinext] No build output found in /path/to/app/dist
Run `vinext build` first.

dist/ is populated — just not where the Node server looks.

Cause

startProdServer (dist/server/prod-server.js) probes two fixed paths:

const rscEntryPath    = path.join(resolvedOutDir, "server", "index.js"); // App Router
const serverEntryPath = path.join(resolvedOutDir, "server", "entry.js"); // Pages Router
const isAppRouter = fs.existsSync(rscEntryPath);
if (!isAppRouter && !fs.existsSync(serverEntryPath)) {
  console.error(`[vinext] No build output found in ${outDir}`);

With @cloudflare/vite-plugin, the Worker is emitted to dist/<worker-name>/index.js per the plugin's convention, so neither path exists unless the Worker happens to be named server.

Even if the path were corrected, running a Cloudflare build under the Node server is the wrong runtime: the point of building for Workers is to exercise it on workerd, where the available APIs differ.

Reproduction

vinext init --platform cloudflare --skip-check
vinext build
vinext start          # -> "No build output found"

Running Wrangler directly against the emitted config does start the Worker:

wrangler dev --config dist/<worker-name>/wrangler.json

Expected

For a project configured for Cloudflare, vinext start runs the built Worker on workerd via Wrangler, using the emitted dist/<worker-name>/wrangler.json — matching what init advertises. Node projects keep the current behaviour.

Detecting the platform from the presence of @cloudflare/vite-plugin in the Vite config (or a wrangler.jsonc in the project root) would let one command do the right thing for both targets. Failing that, init should at minimum scaffold a start:vinext that calls Wrangler for Cloudflare projects, and the "No build output found" message should mention the Cloudflare output location.

Environment

  • vinext 1.0.0-beta.6
  • @cloudflare/vite-plugin, wrangler 4.123.0
  • Vite 8.1.0
  • Pages Router, vinext init --platform cloudflare

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions