From 29c086779bdeaebfa22e306013b2eb8562a8163c Mon Sep 17 00:00:00 2001 From: Dada1981 Date: Thu, 11 Jun 2026 22:48:21 +0200 Subject: [PATCH] fix: improve path resolution compatibility Update path resolution logic to handle both ESM and CJS environments safely, ensuring compatibility during build processes and runtime execution. --- server.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server.ts b/server.ts index 118823e..06655b8 100644 --- a/server.ts +++ b/server.ts @@ -9,8 +9,13 @@ import { AuthorData } from "./src/types.js"; dotenv.config(); -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); +const currentFilename = typeof import.meta !== "undefined" && import.meta.url + ? fileURLToPath(import.meta.url) + : (typeof __filename !== "undefined" ? __filename : ""); + +const currentDirname = typeof import.meta !== "undefined" && import.meta.url + ? path.dirname(currentFilename) + : (typeof __dirname !== "undefined" ? __dirname : ""); const app = express(); const PORT = 3000;