Next.js Discord

Discord Forum

Next.js 14 not working with Next-Auth?

Unanswered
Artois Hound posted this in #help-forum
Open in Discord
Artois HoundOP
When I try to update, I get:
Found: next@14.0.0
npm ERR! node_modules/next
npm ERR!   next@"^14.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer next@"^12.2.5 || ^13" from next-auth@4.24.3
npm ERR! node_modules/next-auth
npm ERR!   next-auth@"^4.24.3" from the root project

15 Replies

Artois HoundOP
I still tried to force the update, and it all seemed to work well nevertheless, but I reverted since there might be hidden problems.
Considering 14 released today, it may take a few hours/days for auth to update. When the appdirectory released, they updated pretty quickly.
Exotic Shorthair
I'm not having issues, but im using 4.23.1. Try downgrading and see if that fixes it?
Giant panda
You gotta wait for next-auth to upgrade their package, that's all
@Exotic Shorthair I'm not having issues, but im using 4.23.1. Try downgrading and see if that fixes it?
Artois HoundOP
I had 4.23.1 originally, but i upgraded thinking that it might fix it.
@Matt https://nextjs.org/learn/dashboard-app/adding-authentication Recommends using <@270688266779361280>
Artois HoundOP
Yep,
npm install next-auth@beta next
works
But it's resulting in some header errors on a trial run, so I guess I'll just wait for the official release
Error: Invariant: headers() expects to have requestAsyncStorage, none available.
@Artois Hound this one?
@Artois Hound When I try to update, I get: Found: next@14.0.0 npm ERR! node_modules/next npm ERR! next@"^14.0.0" from the root project npm ERR! npm ERR! Could not resolve dependency: npm ERR! peer next@"^12.2.5 || ^13" from next-auth@4.24.3 npm ERR! node_modules/next-auth npm ERR! next-auth@"^4.24.3" from the root project
this is a peer dependency issue. all packages that list next as one of the peer dependencies cannot work with next 14, next-auth included. you have to wait for a new next-auth version to be released
@Matt Error: Invariant: headers() expects to have requestAsyncStorage, none available. <@541560836729208833> this one?
Artois HoundOP
Nope, it was smth with imports? maybe they changed the package for headers or idk
@Matt Error: Invariant: headers() expects to have requestAsyncStorage, none available. <@541560836729208833> this one?
Artois HoundOP
⨯ Error [ERR_MODULE_NOT_FOUND]: Cannot find module '\node_modules\next\headers' imported from \node_modules\next-auth\lib\index.js
Did you mean to import next/headers.js?
    at new NodeError (node:internal/errors:399:5)
    at finalizeResolution (node:internal/modules/esm/resolve:232:11)
    at moduleResolve (node:internal/modules/esm/resolve:850:10)
    at defaultResolve (node:internal/modules/esm/resolve:1070:11)
    at DefaultModuleLoader.resolve (node:internal/modules/esm/loader:306:12)
    at DefaultModuleLoader.getModuleJob (node:internal/modules/esm/loader:155:32)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:33)
    at link (node:internal/modules/esm/module_job:75:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}
And this was with the beta next-auth 5.0, so ig we just gotta wait for a full release
Strange. For what it's worth it's working for me locally, so might be worth a wipe/cache clean and retry
Artois HoundOP
I mean I got it working with the original next-auth not the beta version, by forcing the next update, but I didn't really notice 53% faster local server startup like the announcement claimed so ig I'll just wait for the full update