Pages Function Fails: "Dynamic require" Error Despite nodejs_compat Flag
My Cloudflare Pages Function, which uses an Express server, is failing at runtime with the error: Uncaught Error: Dynamic require of "node:events" is not supported.
We have already taken the following troubleshooting steps:
Confirmed the nodejs_compat flag is in our wrangler.toml.
Confirmed the nodejs_compat flag is set correctly in the Pages project settings UI for both Production and Preview.
Completely deleted and recreated the Pages project from scratch, setting the flag during the initial setup wizard.
Despite these steps, the runtime environment is still not applying the compatibility flag. Please advise.
We have already taken the following troubleshooting steps:
Confirmed the nodejs_compat flag is in our wrangler.toml.
Confirmed the nodejs_compat flag is set correctly in the Pages project settings UI for both Production and Preview.
Completely deleted and recreated the Pages project from scratch, setting the flag during the initial setup wizard.
Despite these steps, the runtime environment is still not applying the compatibility flag. Please advise.