nextauthjs / next-auth

Authentication for the Web.
https://authjs.dev
ISC License
23.79k stars 3.27k forks source link

Fastify app not compiling `Package subpath './providers/github' is not defined by "exports" in .../@auth/core/package.json` #7049

Closed statusunknown418 closed 1 year ago

statusunknown418 commented 1 year ago

Provider type

GitHub

Environment

System: OS: macOS 13.2.1 CPU: (8) arm64 Apple M1 Pro Memory: 1.47 GB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 19.8.1 - /opt/homebrew/bin/node npm: 9.5.1 - /opt/homebrew/bin/npm Watchman: 2023.01.16.00 - /opt/homebrew/bin/watchman Browsers: Safari: 16.3

Reproduction URL

https://github.com/AlvaroAquijeDiaz/next-auth-bug-report

Describe the issue

I'm using fastify-next-auth to glue together next-auth and fastify due to current needs, but I'm getting this error everytime I try to start the server.

How to reproduce

start the server

Expected behavior

it should compile and actually work as when using it directly on Next.js

balazsorban44 commented 1 year ago

The package does have the correct export field, the issue is somewhere else. See https://github.com/nextauthjs/next-auth/blob/aadefc6fbdb9622edc549332a4f222b94302640e/packages/core/package.json#L54-L57

supbath patterns have been supported in Node.js for a while, so it might be an issue with your tooling somewhere. 🤔

https://nodejs.org/api/packages.html#subpath-patterns

statusunknown418 commented 1 year ago

The package does have the correct export field, the issue is somewhere else. See https://github.com/nextauthjs/next-auth/blob/aadefc6fbdb9622edc549332a4f222b94302640e/packages/core/package.json#L54-L57

supbath patterns have been supported in Node.js for a while, so it might be an issue with your tooling somewhere. 🤔

https://nodejs.org/api/packages.html#subpath-patterns

So it's probably an issue with the library itself? I'll forward this to it then, thanks

wanjas commented 11 months ago

@AlvaroAquijeDiaz I bumped into the same issue. Looks like it's ES modules problem in CJS.

I've managed to import the library like this:

  const AuthPlugin = (await import('fastify-next-auth')).default;
  const GoogleProvider = (await import('@auth/core/providers/google')).default;