Ensure nodejs_compat is set in wrangler.json or wrangler.toml
"compatibility_flags": [ "nodejs_compat" ],
| import * as process from 'node:process' | |
| app.use((c, next) => { | |
| Object.entries(c.env).forEach(([key, value]) => { | |
| process.env[key] = value | |
| }) | |
| next() | |
| }) | |
| // Then use the following within the worker | |
| import * as process from 'node:process' | |
| console.log(process.env) |