You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
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
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.
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/.
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.
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:
opennextjs-cloudflare build → .open-next
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.
worker.js has relative imports into .open-next/*, so we bundle it into a single file first (wrangler deploy --dry-run --outdir).
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.
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.
Activity
Masaki-Ogawa commentedon Sep 29, 2026
Hitting the same limitation with Next.js 16 +
@opennextjs/cloudflare1.19.11 (cf 1.0.0-beta.5):We deploy several Workers per environment and switch worker
nameand vars viactx.modeincloudflare.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:opennextjs-cloudflare build→.open-nextcloudflare.config.tsfor the mode and write.cloudflare/output/v0/workers/default/worker.config.json(manifest: { type: "partial", mainModule: "worker.js", modules: {} }—modulesis required even for a partial manifest), copy.open-next/assetstoassets/, and writeconfig.jsonwithbuildContext.mode.worker.jshas relative imports into.open-next/*, so we bundle it into a single file first (wrangler deploy --dry-run --outdir).cf deploy --prebuilt --mode staging--prebuiltalso 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
--modeselect 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.workers-devprod commentedon Nov 24, 2026
Thanks for the detailed report.
cf buildandcf deploydeliberately pass--modeon 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 tocloudflare.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.