Replies: 8 comments 8 replies
-
Did you get anything here yet? I have this exact same error... |
Beta Was this translation helpful? Give feedback.
-
Same here, with same environment (pages architecture) "next-auth": "^5.0.0-beta.11" |
Beta Was this translation helpful? Give feedback.
-
I fixed it by using "next": "14.1.4" |
Beta Was this translation helpful? Give feedback.
-
i like the comment in
|
Beta Was this translation helpful? Give feedback.
-
is there any workaround for that? why should I go back to 14.1.4 for that? :( |
Beta Was this translation helpful? Give feedback.
-
I have the same error. Im currently migrating from Pages Router to App Router. My approach is to first upgrade Next.js and all related libraries, adapt to the new APIs, and ensure everything works as expected with the Pages Router. Once that’s stable, I’ll proceed with the migration to the App Router. ⨯ [Error: Cannot find module '/node_modules/next/server' imported from /node_modules/next-auth/lib/env.js
Did you mean to import next/server.js?] {
code: 'ERR_MODULE_NOT_FOUND',
url: 'file:///node_modules/next/server'
} my dependencies: {
"next": "15.0.3",
"next-auth": "^5.0.0-beta.25"
} |
Beta Was this translation helpful? Give feedback.
-
Has anyone found a work around? |
Beta Was this translation helpful? Give feedback.
-
Hey there! Thank you so much for posting this – I ran into the same error last night and for some reason, the formatting of the message in your post really clarified what the error was saying. I became determined to fix it and...I think I did! Or at least I have some sort of work-around. Please read this full post because I ran into some additional errors once the original one was fixed. MODAL NOT FOUND FixThe error message specifies a file location and a suggested import. Go to the folder indicated after the "imported from" wording (in the case of the original post, it was /node_modules/next-auth/lib/). Open the following files:
(Yes, the .js files – NOT the other ones ending in .ts(.map)!) Update the following imports by adding ".js" at the end of them:
You can also search for the comment "ts-expect-error Next.js does not yet correctly use the This should resolve that specific issue. That being said, I ran into two additional issues after I resolved this one that you may want to resolve first. Additional Issues⨯ Error: Could not parse module '[project]/node_modules/next/dist/server/route-modules/app-route/vendored/contexts/app-router-context.js'I'm happy to say that this is an easy enough fix – remove Turbopack (--turbo) from the next dev command in package.json. (Credit to a comment on Reddit for this. It does look like a know issue that will be fixed sometime in the next release, so Turbopack doesn't have to stay off forever.) ⨯ TypeError: (0 , react__WEBPACK_IMPORTED_MODULE_1__.cache) is not a function at uncachedAuth (src/server/auth/index.ts:8:19)
Everything else ran as expected. I hope this is helpful to somebody! |
Beta Was this translation helpful? Give feedback.
-
I have been trying to use the new auth.js so I have "next": "^14.1.0",
"next-auth": "^5.0.0-beta.11", I am still using pages though as well. I am trying to migrate from using Next.js 13.4 and MSAL to using next-auth. I have an auth.ts, auth.config.ts, my nextauth api and a middleware. I keep getting this error though while trying to login or calling getSession() as it seems when my app hits the api/auth/error I get a 500 and the error reads:
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/node_modules/next/server' imported from /node_modules/next-auth/lib/env.js
Did you mean to import "next/server.js"?
I have tried looking everywhere but can't find any information about this error and what might be causing it. Hopefully I can find someone here who knows what the deal might be. Thank you!
Beta Was this translation helpful? Give feedback.
All reactions