Set compatibility date and nodejs_compat for dev
cloudflare pages
// what it does
Sets the runtime compatibility date and flags for local dev so Functions behave like a matching production deployment. Add `nodejs_compat` when your code imports Node built-ins such as `node:buffer` or `node:crypto`.
// shell
$ wrangler pages dev ./dist --compatibility-date 2024-09-23 --compatibility-flag nodejs_compat// gotcha
These flags configure local dev only — production reads compatibility settings from the dashboard or `wrangler.jsonc`, so set them there too or dev and prod will silently diverge.