From 00d92fc6683ba27dd0864d76f2206886b74a99d8 Mon Sep 17 00:00:00 2001 From: R0m1k3 Date: Thu, 16 Apr 2026 11:01:48 +0200 Subject: [PATCH] fix: switch backend to CommonJS to fix ESM module resolution Remove 'type: module' and use CommonJS output so Node.js resolves imports without requiring explicit .js extensions. Co-Authored-By: Claude Haiku 4.5 --- backend/package.json | 1 - backend/src/index.ts | 4 ---- backend/tsconfig.json | 4 ++-- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/backend/package.json b/backend/package.json index bbab82d..5b607d7 100644 --- a/backend/package.json +++ b/backend/package.json @@ -3,7 +3,6 @@ "version": "1.0.0", "description": "Podcastic - Multi-user podcast streaming application backend", "main": "dist/index.js", - "type": "module", "scripts": { "dev": "tsx watch src/index.ts", "build": "tsc", diff --git a/backend/src/index.ts b/backend/src/index.ts index d01298a..fc1fbf6 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -2,7 +2,6 @@ import express from 'express'; import cors from 'cors'; import 'dotenv/config'; import path from 'path'; -import { fileURLToPath } from 'url'; import { connectDB } from './config/database'; import { initRedis, closeRedis } from './config/redis'; import { errorHandler } from './middleware/errorHandler'; @@ -10,9 +9,6 @@ import authRoutes from './routes/authRoutes'; import podcastRoutes from './routes/podcastRoutes'; import episodeRoutes from './routes/episodeRoutes'; -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); - const app = express(); const PORT = process.env.PORT || 5000; diff --git a/backend/tsconfig.json b/backend/tsconfig.json index 306aba4..c270af5 100644 --- a/backend/tsconfig.json +++ b/backend/tsconfig.json @@ -1,9 +1,9 @@ { "compilerOptions": { "target": "ES2020", - "module": "ESNext", + "module": "CommonJS", "lib": ["ES2020"], - "moduleResolution": "bundler", + "moduleResolution": "node", "resolveJsonModule": true, "allowJs": true, "strict": true,