How to source process.env in monorepo in a worker?

I have a simple email worker. My registry imported from another package is erroring by not finding the env vars that are being parsed I am running the script in package.json "dev:email": "dotenv -e ../../.env -- bun run wrangler dev -c src/cloudflare/email/wrangler.jsonc", I can confirm that dotenv is picking up the env file
[wrangler:inf] Ready on http://localhost:8787
✘ [ERROR] service core:user:email-service: Uncaught Error: TraversalError:
OPENAI_API_KEY must be a string (was missing)
OPENROUTER_API_KEY must be a string (was missing)
at null.<anonymous> (index.js:11262:12) in toTraversalError
at null.<anonymous> (index.js:11255:16) in throw
at null.<anonymous> (index.js:11687:108)
at null.<anonymous> (index.js:11470:23) in finalize
at null.<anonymous> (index.js:11644:22)
[wrangler:inf] Ready on http://localhost:8787
✘ [ERROR] service core:user:email-service: Uncaught Error: TraversalError:
OPENAI_API_KEY must be a string (was missing)
OPENROUTER_API_KEY must be a string (was missing)
at null.<anonymous> (index.js:11262:12) in toTraversalError
at null.<anonymous> (index.js:11255:16) in throw
at null.<anonymous> (index.js:11687:108)
at null.<anonymous> (index.js:11470:23) in finalize
at null.<anonymous> (index.js:11644:22)
No description
3 Replies
DiamondDragon
DiamondDragonOP2w ago
Ok - since this is running on wrangler local... maybe it needs .dev.vars ? How do i source that from the root in a monorepo?
olafg
olafg2w ago
I am not sure you can... I am adding .dev.vars at the same level as each wrangler config
DiamondDragon
DiamondDragonOP2w ago
ugh that is so annyoing

Did you find this page helpful?