skip to Main Content

I’m using nextjs and nextauth on nginx. I’m getting a build fail but I’m not sure how to fix this error.

2021-12-06T09:35:02.4779281Z https://nextjs.org/telemetry

2021-12-06T09:35:02.4779648Z

2021-12-06T09:35:02.7626345Z info - Checking validity of types...

2021-12-06T09:35:03.6479273Z warn - No ESLint configuration detected. Run next lint to begin setup

2021-12-06T09:35:03.6504824Z info - Creating an optimized production build...

2021-12-06T09:35:11.0167427Z Failed to compile.

2021-12-06T09:35:11.0168180Z

2021-12-06T09:35:11.0173424Z ModuleNotFoundError: Module not found: Error: Package path ./client is not exported from package /var/www/html/node_modules/next-auth (see exports field in /var/www/html/node_modules/next-auth/package.json)

2021-12-06T09:35:11.0177457Z

2021-12-06T09:35:11.0181521Z

2021-12-06T09:35:11.0184681Z > Build error occurred

2021-12-06T09:35:11.0202372Z Error: > Build failed because of webpack errors

2021-12-06T09:35:11.0203202Z at nextBuildSpan.traceAsyncFn (/var/www/html/node_modules/next/dist/build/index.js:397:19)

2021-12-06T09:35:11.0490267Z npm ERR! code ELIFECYCLE

2021-12-06T09:35:11.0502899Z npm ERR! errno 1

2021-12-06T09:35:11.0522169Z npm ERR! [email protected] build: `next build`

2021-12-06T09:35:11.0529617Z npm ERR! Exit status 1

2021-12-06T09:35:11.0538648Z npm ERR!

2021-12-06T09:35:11.0546568Z npm ERR! Failed at the [email protected] build script.

2021-12-06T09:35:11.0554061Z npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

2021-12-06T09:35:11.0650303Z

2021-12-06T09:35:11.0658427Z npm ERR! A complete log of this run can be found in:

2021-12-06T09:35:11.0665933Z npm ERR! /home/ubuntu/.npm/_logs/2021-12-06T09_35_11_056Z-debug.log

2021-12-06T09:35:11.0875406Z ##[error]Bash exited with code '1'.

2021-12-06T09:35:11.0952428Z ##[section]Finishing: npm run build

Any help with what to do next? How do I fix this problem? I’ve been struggling with this error all morning today.

3

Answers


  1. It seems next-auth/client was renamed to next-auth/react in v4:

    https://github.com/nextauthjs/next-auth/releases/tag/v4.0.0-beta.1

    Login or Signup to reply.
  2. Along with next-auth/react, Provide was renamed to SessionProvider. It should be as follows,

    import { SessionProvider } from "next-auth/react"
    
    export default function App({
      Component,
      pageProps: { session, ...pageProps },
    }) {
      return (
        <SessionProvider session={session} refetchInterval={5 * 60}>
          <Component {...pageProps} />
        </SessionProvider>
      )
    }
    

    https://next-auth.js.org/getting-started/upgrade-v4

    Login or Signup to reply.
  3. i think you should use "next-auth": "^3.29.0", this version of next-auth

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search