NextAuth >= v4.23.0 Breaking change: - Package subpath './core' is not defined by "exports"
Environment
- Operating System: Windows_NT
- Node Version: v18.16.1
- Nuxt Version: 3.6.5
- Nitro Version: 2.5.2
- Package Manager: [email protected]
- Builder: vite
- User Config: experimental, postcss, build, vite, typescript, vue, nitro, modules, googleFonts, ui, htmlValidator, apollo, graphqlServer, content, runtimeConfig, app, devtools
- Runtime Modules: @nuxtjs/[email protected], @sidebase/[email protected], [email protected], @nuxtjs/[email protected], @nuxthq/[email protected], @nuxt/[email protected]
- Build Modules: -
Reproduction
n/a
Describe the bug
When doing a clean install with no package-lock.json, the next-auth package installed along with nuxt-auth module seem to have breaking changes in import namespaces used by the nuxtAuthHandler file.
Additional context
A current workaround is pinning next-auth to v4.22.5
Logs
ℹ Vite client warmed up in 8934ms 01:51:59
[01:52:01] WARN (node-resolve plugin) Could not resolve import "next-auth/core" in C:\dev\monorepo\web\node_modules\@sidebase\nuxt-auth\dist\runtime\server\services\authjs\nuxtAuthHandler.mjs using exports defined in C:\dev\monorepo\web\node_modules\next-auth\package.json.
[01:52:01] WARN (node-resolve plugin) Could not resolve import "next-auth/core" in C:\dev\monorepo\web\node_modules\@sidebase\nuxt-auth\dist\runtime\server\services\authjs\nuxtAuthHandler.mjs using exports defined in C:\dev\monorepo\web\node_modules\next-auth\package.json.
[01:52:01] WARN (node-resolve plugin) Could not resolve import "next-auth/core" in C:\dev\monorepo\web\node_modules\@sidebase\nuxt-auth\dist\runtime\server\services\authjs\nuxtAuthHandler.mjs using exports defined in C:\dev\monorepo\web\node_modules\next-auth\package.json.
[01:52:01] WARN (node-resolve plugin) Could not resolve import "next-auth/core" in C:\dev\monorepo\web\node_modules\@sidebase\nuxt-auth\dist\runtime\server\services\authjs\nuxtAuthHandler.mjs using exports defined in C:\dev\monorepo\web\node_modules\next-auth\package.json.
[01:52:01] WARN (node-resolve plugin) Could not resolve import "next-auth/core" in C:\dev\monorepo\web\node_modules\@sidebase\nuxt-auth\dist\runtime\server\services\authjs\nuxtAuthHandler.mjs using exports defined in C:\dev\monorepo\web\node_modules\next-auth\package.json.
[01:52:01] WARN "next-auth/core" is imported by "node_modules/@sidebase/nuxt-auth/dist/runtime/server/services/authjs/nuxtAuthHandler.mjs", but could not be resolved – treating it as an external dependency.
✔ Nitro built in 5761 ms nitro 01:52:03
[01:52:03] ERROR [worker reload] [worker init] Package subpath './core' is not defined by "exports" in C:\dev\monorepo\web\node_modules\next-auth\package.json imported from C:\dev\monorepo\web\.nuxt\dev\index.mjs
at new NodeError (node:internal/errors:399:5)
at exportsNotFound (node:internal/modules/esm/resolve:361:10)
at packageExportsResolve (node:internal/modules/esm/resolve:697:9)
at packageResolve (node:internal/modules/esm/resolve:872:14)
at moduleResolve (node:internal/modules/esm/resolve:938:20)
at defaultResolve (node:internal/modules/esm/resolve:1153:11)
at nextResolve (node:internal/modules/esm/loader:163:28)
at ESMLoader.resolve (node:internal/modules/esm/loader:838:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:77:40)
Exact same problem here. My workaround also was to pin next-auth, but the version I have used is from the nuxt-auth docs: [email protected].
So nuxt-auth docs said that we should use [email protected] I did that... but your solution sounds better.
same problem here...
faced the same problem, reverting to [email protected] fixed it.
same problem here...
@SherifAugustus where exactly should I revert the next-auth version?
@kennedyngigi4 just install the specific next-auth version to your project, then nuxt-auth will use that one
same issue exists in [email protected], but it works with [email protected].
Same problem
4.23.2 same issue.
Hello,I'm also having this problem. What does pinning mean and how to do that?
Thanks
@dingkai031 in the package.json file make sure that the next-auth version number does not have a tilde (^) so it should look like "next-auth": "4.21.1"
After removing it, make sure to run an install command again so that the pinned version is the one installed
Hi @sduduzog and everyone else!
I just tested the newest version of NextAuth (4.23.2) and it seems to have resolved the issue! You should be able to use the newest version again, as they undid their change with the exports! Therefore I will be closing this issue!
#Hi @sduduzog and everyone else!
I just tested the newest version of NextAuth (4.23.2) and it seems to have resolved the issue! You should be able to use the newest version again, as they undid their change with the exports! Therefore I will be closing this issue!
Hey just tested this with 4.23.2 and the bug is still there. This shouldn't be closed yet.
#Hi @sduduzog and everyone else!
I just tested the newest version of NextAuth (4.23.2) and it seems to have resolved the issue! You should be able to use the newest version again, as they undid their change with the exports! Therefore I will be closing this issue!
Hey just tested this with 4.23.2 and the bug is still there. This shouldn't be closed yet.
Yes. The error remains
Too bad, Ill keep this open. Maybe someone wants to open a PR on the offical NextAuth repo or pressure them more into reverting this change! I had mentioned it before in the commit comments, but received no answer...
I confirm that 4.32.2 doesn't fix the issue, I rollback to 4.21.1 as mentioned previously.
I upgraded to 4.24.3 and this issue continue
For anyone else wondering how to go about this
Just run this
npm install [email protected] --save-exact=true
I upgraded to 4.24.4 and this issue continue