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) #760
workers-devprod
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Moved from #45. Originally opened by tammai on 2026-09-29.
What happened
In a Nuxt 4 project (Nitro
cloudflare_modulepreset),cf deploy --mode previewstops before building:The same thing happens with
--dry-run. So a Nuxt project can't select any environment besides the default, anddefineConfig((ctx) => …)'sctx.modecan't be used to switch bindings between production and a preview or staging Worker.Setup
cf1.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 withspawn EFTYPEwhen delegating to Wrangler #19) doesn't apply here.cloudflare_module.@cloudflare/vite-pluginisn't installed.cloudflare.config.tsswitches onctx.mode:defaultfor production,previewfor a separate<name>-previewWorker 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 builditself succeeds just before this, as a separate build step.Expected
Either:
--modestill selects thecloudflare.config.tsbranch when the detected framework can't take a mode (the mode doesn't need to reachnuxt build), or--prebuiltaccepting.output/.Related
--mode.Workaround
Confirmed on 2026-09-29 in Workers Builds:
cf d1 migrations apply <database-id> --dir migrations, thenwrangler deploy --env preview, deploys the same project. Thecfmigration used the existingd1_migrationstable as expected. So we keep the upload on Wrangler and usecffor everything else.Masaki-Ogawa commented on 2026-09-29:
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.All reactions