Skip to content

cf deploy --mode <name> fails on Nuxt projects: 'The detected command pnpm nuxt build does not currently support --mode' (1.0.0-beta.5) #45

Not planned

Description

@tammai

What happened

In a Nuxt 4 project (Nitro cloudflare_module preset), cf deploy --mode preview stops before building:

$ cf deploy --mode preview --worker staff-hub-preview --dry-run
┌ Error
│ The detected command `pnpm nuxt build` does not currently support `--mode`.
└

The same thing happens with --dry-run. So a Nuxt project can't select any environment besides the default, and defineConfig((ctx) => …)'s ctx.mode can't be used to switch bindings between production and a preview or staging Worker.

Setup

  • cf 1.0.0-beta.5, run in Cloudflare Workers Builds (Linux, Node 24.18, pnpm 10.25). The Windows spawn issue (Windows: cf build / dev / deploy fail with spawn EFTYPE when delegating to Wrangler #19) doesn't apply here.
  • Nuxt 4.5, Nitro preset cloudflare_module. @cloudflare/vite-plugin isn't installed.
  • cloudflare.config.ts switches on ctx.mode: default for production, preview for a separate <name>-preview Worker with its own D1 and KV. It was written from the codemod's output shape (worker.name, entrypoint: './.output/server/index.mjs', bindings.d1/kv/text/assets).
  • nuxt build itself succeeds just before this, as a separate build step.

Expected

Either:

  • --mode still selects the cloudflare.config.ts branch when the detected framework can't take a mode (the mode doesn't need to reach nuxt build), or
  • a way to skip the framework build and deploy an existing Nitro output with a chosen mode, for example --prebuilt accepting .output/.

Related

Workaround

Confirmed on 2026-09-29 in Workers Builds: cf d1 migrations apply <database-id> --dir migrations, then wrangler deploy --env preview, deploys the same project. The cf migration used the existing d1_migrations table as expected. So we keep the upload on Wrangler and use cf for everything else.

Activity

  1. assigned and unassigned on Sep 29, 2026
  2. Masaki-Ogawa commented on Sep 29, 2026

    @Masaki-Ogawa

    Hitting the same limitation with Next.js 16 + @opennextjs/cloudflare 1.19.11 (cf 1.0.0-beta.5):

    $ cf deploy --mode staging
    The detected command `npx next build` does not currently support `--mode`.
    

    We deploy several Workers per environment and switch worker name and vars via ctx.mode in cloudflare.config.ts, so this blocks the migration for Next.js projects.

    Workaround that works for us: build with OpenNext first, then assemble the Build Output Specification ourselves and deploy with --prebuilt:

    1. opennextjs-cloudflare build → .open-next
    2. Evaluate cloudflare.config.ts for the mode and write .cloudflare/output/v0/workers/default/worker.config.json (manifest: { type: "partial", mainModule: "worker.js", modules: {} } — modules is required even for a partial manifest), copy .open-next/assets to assets/, and write config.json with buildContext.mode.
    3. worker.js has relative imports into .open-next/*, so we bundle it into a single file first (wrangler deploy --dry-run --outdir).
    4. cf deploy --prebuilt --mode staging

    --prebuilt also correctly rejects a mode mismatch with the existing output, which is a nice safety net.

    This suggests the same fix as proposed in the issue: let --mode select the config branch without forwarding it to the framework build. An official way to produce the prebuilt output for OpenNext (or accepting the OpenNext output directly) would remove the need for our custom script.

  3. added theissue type on Sep 30, 2026
  4. workers-devprod commented on Nov 24, 2026

    @workers-devprod
    Collaborator

    Thanks for the detailed report. cf build and cf deploy deliberately pass --mode on to the framework's own build, so they refuse it for frameworks that don't accept a mode yet, Nuxt and Next.js among them. Applying the mode only to cloudflare.config.ts, or deploying existing Nitro or OpenNext output directly, would be a change to cf. We track that at #760, so please follow and upvote it there.

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

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions