Go to the Pages project settings page (Settings > Functions > Compatibility Flags), add the nodejs_c
Go to the Pages project settings page (Settings > Functions > Compatibility Flags), add the nodejs_compat flag for both production and preview
next dev this isn't available@cloudflare/next-on-pages to build, then wrangler pages dev.next dev

@cloudflare/next-on-pages