Search code examples
typescriptnext.jsnext-auth

Next-auth failed during building nextjs app


I am using next-auth in my nextjs app.

npm install and npm run dev works fine, and also the authentication works locally. But when I run the build command I get this error message:

./node_modules/next-auth/next/index.d.ts:18:61
Type error: '>' expected.

  16 | export declare function unstable_getServerSession<O extends GetServerSessionOptions, R = O["callbacks"] extends {
  17 |     session: (...args: any[]) => infer U;
> 18 | } ? U : Session>(...args: Parameters<typeof getServerSession<O, R>>): ReturnType<typeof getServerSession<O, R>>;
     |                                                             ^
  19 | declare global {
  20 |     namespace NodeJS {
  21 |         interface ProcessEnv 

My dependencies in package.json looks are:

"dependencies": {
    "@prisma/client": "^4.6.1",
    "next": "13.0.2",
    "next-auth": "^4.3.3",
    "next-transpile-modules": "^10.0.0",
    "nodemailer": "^6.9.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-markdown": "8.0.0",
    "ts-node": "^10.9.1"
},

The only thing I found during searching the web is this bug-report 4 hours ago. Could it be a bug in next-auth ?

Thanks for helping.

I tried to use different versions of nextjs and next-auth but nothing changes.


Solution

  • Got information from a lead developer of next auth:

    A fix is going out via this PR: https://github.com/nextauthjs/next-auth/pull/6595 - 4.19.2 should not have this issue anymore!