Need some help with setting up Express with Next

I'm trying to use Express with Next but it's not working I'm getting this
[nodemon] starting `ts-node --project tsconfig.server.json src/server.ts -- -I`
C:\Users\Aditya\AppData\Local\pnpm\global\5\.pnpm\[email protected]_@[email protected][email protected]\node_modules\ts-node\src\index.ts:859
return new TSError(diagnosticText, diagnosticCodes, diagnostics);
^
TSError: ⨯ Unable to compile TypeScript:
src/server/auth/index.ts:1:31 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@lucia-auth/adapter-prisma")' call instead.
To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `"type": "module"` to 'F:/Projects/Web/temp/test2/package.json'.

1 import { PrismaAdapter } from "@lucia-auth/adapter-prisma";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/server/auth/index.ts:2:38 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("lucia")' call instead.
To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `"type": "module"` to 'F:/Projects/Web/temp/test2/package.json'.

2 import { Lucia, Session, User } from "lucia";
~~~~~~~
[nodemon] starting `ts-node --project tsconfig.server.json src/server.ts -- -I`
C:\Users\Aditya\AppData\Local\pnpm\global\5\.pnpm\[email protected]_@[email protected][email protected]\node_modules\ts-node\src\index.ts:859
return new TSError(diagnosticText, diagnosticCodes, diagnostics);
^
TSError: ⨯ Unable to compile TypeScript:
src/server/auth/index.ts:1:31 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@lucia-auth/adapter-prisma")' call instead.
To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `"type": "module"` to 'F:/Projects/Web/temp/test2/package.json'.

1 import { PrismaAdapter } from "@lucia-auth/adapter-prisma";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/server/auth/index.ts:2:38 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("lucia")' call instead.
To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `"type": "module"` to 'F:/Projects/Web/temp/test2/package.json'.

2 import { Lucia, Session, User } from "lucia";
~~~~~~~
I've tried changing to .mts .cts nothing works Here is my ts.server.config
No description
4 Replies
aditya
adityaOP4mo ago
Here is package.json
aditya
adityaOP4mo ago
No description
Matvey
Matvey4mo ago
why do you need express, just make your backend in nextjs you most likely need "type": "module" in your package.json
aditya
adityaOP4mo ago
tried that, it doesn't detect.ts files when i do that well yeah but i need express sadly😭
Want results from more Discord servers?
Add your server