Recently experienced this issue with my Next.js project. After successfully building and deploying, an error appeared on my project URL:
Error: Built-in Node.js modules inaccessible. Ensure 'nodejs_compat' compatibility flag is enabled in your Cloudflare Pages project.
Enabled the nodejs_compat
flag and tried deploying again - success!
However, I found the documentation to be a bit ambiguous on how to add the "nodejs_compat" flag from the Cloudflare dashboard -> Workers & Pages -> Your Pages project -> Settings -> Functions -> Compatibility Flags. It only shows an example of adding it in wrangler.toml format:
compatibility_flags = [ "nodejs_compat" ]
If you wish to add the "nodejs_compat" flag from the Cloudflare dashboard, simply enter the flag as plain text: nodejs_compat
. No quotes, brackets, or additional words needed.