nuxt-auth icon indicating copy to clipboard operation
nuxt-auth copied to clipboard

NextAuth >= v4.23.0 Breaking change: - Package subpath './core' is not defined by "exports"

Open sduduzog opened this issue 3 years ago • 40 comments

Environment



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)

sduduzog avatar Aug 14 '23 00:08 sduduzog

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.

Sparo avatar Aug 14 '23 02:08 Sparo

same problem here...

Salotronic avatar Aug 16 '23 12:08 Salotronic

faced the same problem, reverting to [email protected] fixed it.

SherifAugustus avatar Aug 16 '23 14:08 SherifAugustus

same problem here...

bjornol avatar Aug 24 '23 12:08 bjornol

@SherifAugustus where exactly should I revert the next-auth version?

kennedyngigi4 avatar Aug 25 '23 12:08 kennedyngigi4

@kennedyngigi4 just install the specific next-auth version to your project, then nuxt-auth will use that one

sduduzog avatar Aug 25 '23 15:08 sduduzog

[email protected]

I had same issue and [email protected] fixed it.

itsalibahadori avatar Sep 02 '23 11:09 itsalibahadori

same issue exists in [email protected], but it works with [email protected].

JiangShuuu avatar Sep 05 '23 13:09 JiangShuuu

Same problem

RicLzPt avatar Sep 13 '23 17:09 RicLzPt

4.23.2 same issue.

RicLzPt avatar Oct 02 '23 21:10 RicLzPt

Hello,I'm also having this problem. What does pinning mean and how to do that?

Thanks

dingkai031 avatar Oct 07 '23 06:10 dingkai031

@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

sduduzog avatar Oct 09 '23 08:10 sduduzog

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!

zoey-kaiser avatar Oct 11 '23 10:10 zoey-kaiser

#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.

greenacresfoundation avatar Oct 12 '23 19:10 greenacresfoundation

#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

RicLzPt avatar Oct 12 '23 19:10 RicLzPt

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...

zoey-kaiser avatar Oct 12 '23 20:10 zoey-kaiser

I confirm that 4.32.2 doesn't fix the issue, I rollback to 4.21.1 as mentioned previously.

RomainMazB avatar Oct 13 '23 08:10 RomainMazB

I upgraded to 4.24.3 and this issue continue

RicLzPt avatar Oct 19 '23 17:10 RicLzPt

For anyone else wondering how to go about this

Just run this

npm install [email protected] --save-exact=true

ize-302 avatar Oct 23 '23 19:10 ize-302

I upgraded to 4.24.4 and this issue continue

RicLzPt avatar Oct 30 '23 13:10 RicLzPt