reactjs - __dirname is not defined, Error When Running wrangler dev - Stack Overflow

admin2025-04-17  5

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.

转载请注明原文地址:http://anycun.com/QandA/1744829998a88205.html