Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: next-auth module completely broken with MODULE_NOT_FOUND next/server.js when doing folder structure instead of app #2033

Open
marcomnrq opened this issue Nov 25, 2024 · 8 comments

Comments

@marcomnrq
Copy link

Provide environment information

Happening in the latest version available: create-t3-app@7.38.1.

Describe the bug

On public and protected routes, the tRPC calls made from the client fail indicating the following error:
Screenshot 2024-11-24 at 7 30 42 PM

 Error: Failed to load external module next-auth: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/marcomnrq/VSCode Projects/examplebug/node_modules/next/server' imported from /Users/marcomnrq/VSCode Projects/examplebug/node_modules/next-auth/lib/env.js
Did you mean to import "next/server.js"?

Reproduction repo

n/a

To reproduce

Create a new app using the following settings.
Screenshot 2024-11-24 at 7 25 09 PM

Start the app with npm run dev and see the console / logs.

Additional information

Happy to help debugging this further, but i think it has to do with the import in this file. Will try to post some findings in this issue.
Screenshot 2024-11-24 at 7 32 33 PM

@marcomnrq
Copy link
Author

This looks to be related > vercel/next.js#64529

@visheshd
Copy link

Getting this with our codebase as well. Just tried to update to the latest t3-boilerplate.

@BrentonBeltrami
Copy link

This is related/duplicate of #2027.
I am also getting this error.

@ari-party
Copy link

@timmatsam
Copy link

Also getting this error - I feel as if it wasn't prudent to update next-auth to the beta version - i'm a bit surprised a non stable version was approved into the t3 app? Was playing around with this to no avail, mapping next-auth to the transpilePackages option in the next config file did not fix it for me as per ari-party's reference. Best thing to do is to use the 7.37.0 version until a fix has been implemented.

@jakerich1
Copy link

This worked for me nextauthjs/next-auth#10058 (comment)

@lfnb
Copy link

lfnb commented Feb 23, 2025

I encountered the same issue and attempted the following solutions to resolve it:

  1. Downgraded t3-app: pnpm create t3-app@7.38.0, ❌
  2. Downgraded next-auth, ❌
  3. Changed the page route to an app route, ✅

@nbibler
Copy link

nbibler commented Mar 31, 2025

Simplest "fix" for this I've currently seen is to modify next.config.js and restart the next dev server:

diff --git a/next.config.js b/next.config.js
index 080cc56..a5c18b9 100644
--- a/next.config.js
+++ b/next.config.js
@@ -17,6 +17,8 @@ const config = {
     locales: ["en"],
     defaultLocale: "en",
   },
+
+  transpilePackages: ["next-auth"],
 };
 
 export default config;

From nextauthjs/next-auth#9385 (comment).

This appears to work as expected with:

├── @auth/prisma-adapter@2.8.0
├── next-auth@5.0.0-beta.25
├── next@15.2.4
├── react-dom@19.1.0
├── react@19.1.0
├── superjson@2.2.2
└── zod@3.24.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants