What is the proper way to use environments with generated wrangler config?
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 899
- Avg merge
- 2d 24m
- Merged PRs (30d)
- 40
Description
Environment
node v22.16.0
wrangler 4.22.0
nitropack 2.11.13
Reproduction
check this code: https://github.com/mohamnag/nitro-wrangler-bug
run: npm run build && npx wrangler dev
see the error
Describe the bug
I have been using wrangler configured with a standalone wrangler.jsonc file to manage deployments to different environments where I just discovered the new cloudflare config for cloudflare_module preset. this would simplify life a bit for me as some things like the compatibility date does not need to be set in many places and things that can be configured by nitro itself can be taken care of too. however it looks like the wrangler does not like the generated file having different environments in it. I'm getting the following error trying to deploy the results or even run it in preview mode:
⛅️ wrangler 4.22.0
───────────────────
Using redirected Wrangler configuration.
- Configuration being used: ".output/server/wrangler.json"
- Original user's configuration: "wrangler.jsonc"
- Deploy configuration file: ".wrangler/deploy/config.json"
✘ [ERROR] Processing .output/server/wrangler.json configuration:
- Redirected configurations cannot include environments but the following have been found:
- production
Such configurations are generated by tools, meaning that one of the tools
your application is using is generating the incorrect configuration.
Report this issue to the tool's author so that this can be fixed there.
I can workaround this by giving wrangler the generated config file directly (i.e. -c .output/server/wrangler.json) but that is a bit shaky to me (as the file can be renamed, ...). Is there a solid concept on how one is supposed to still use the wrangler's feature for managing different environments without this workaround and without hitting that error?
Additional context
No response
Logs
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked reproduction repository and run npm run build && npx wrangler dev using the versions listed in the issue. Inspect .output/server/wrangler.json and the generated configuration error, then trace how the cloudflare_module preset handles environments. Done means establishing a supported environment workflow without relying on a renamed generated file.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- cloud, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100