I am encountering an issue while running wrangler dev. The error indicates that __dirname is not defined in ua-parser-js, which is a dependency used by Next.js.
X [ERROR] service core:user:intonix: Uncaught ReferenceError: __dirname is not defined
at null.<anonymous> (index.js:4387:34)
at null.<anonymous> (index.js:4390:7) in node_modules/next/dist/compiled/ua-parser-js/ua-parser.js
at null.<anonymous> (index.js:32:50) in __require3
at null.<anonymous> (index.js:4426:64) in node_modules/next/dist/server/web/spec- extension/user-agent.js
at null.<anonymous> (index.js:32:50) in __require3
at null.<anonymous> (index.js:6784:28) in node_modules/next/server.js
at null.<anonymous> (index.js:32:50) in __require3
at null.<anonymous> (index.js:16658:29)
OS: Windows
Wrangler Version: 3.107.2
Node.js Version: v20.15.0
Cloudflare Workers Runtime: Latest
I trid to use @cloudflare/next-on-pages but no luck.