-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Module not found: Can't resolve 'crypto' #7527
Comments
Without a reproduction, it's hard to say anything. You likely just need to bump Next.js/Node.js though. We recently made sure that |
Thanks. I will check it out. If not working I'll create a repo to test. |
Found the reason. I was using edge runtime on some routes export const runtime = 'edge'; |
Is there anyway to get this to work with edge runtime? getServerSession on an edge function is giving the above crypto error. I have the latest of all release of next-auth next etc. |
met the same error |
Confirming still an issue on |
Ran into this issue today, running with:
UPDATE: I figured out that I had combined some code in a shared-code library that was "nodejs" runtime and "edge-only" runtime. I had to split it into two different libraries, e.g.
That kept the compiler from trying to combine (unused) library functions that required nodejs (e..g nextauth) into the edge endpoints. |
Noting that NextAuth supports the Edge Runtime in the experimental v5 and this is fixed for me; works great so far. Thanks Balázs and team :) |
I found this on "next-auth": "^4.24.5",
var _crypto = require("crypto"); Can you remove or use crypto-js which supports edge runtime? Or use built-in crypto lib. |
I wasn't first sure why I had this problem because the error is quite misleading, as I was also using "crypto" package to generate a random string. I am using
For me it's this breaks the entire |
Not sure if it helps with this problem but I'd suggest to use version 5, even if it's still in beta |
same issue here... |
FYI, for one app I just moved to iron-session to avoid all those headaches. |
The move itself should take about 2 hours, give or take. Most time will be spent finding the correct version and docs ;) |
I just got everything working on v4 and then I got hit with a |
This comment has been minimized.
This comment has been minimized.
I was getting this error with |
I'm still getting this error using: It seems like this issue was closed a while ago, did I miss some way to get around the error somewhere? |
I'm also getting this error "next": "14.2.3",
"next-auth": "^4.24.7", |
Environment
System:
OS: macOS 13.2.1
CPU: (10) arm64 Apple M1 Pro
Memory: 1.66 GB / 32.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.14.2 - ~/.nvm/versions/node/v18.14.2/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v18.14.2/bin/yarn
npm: 9.5.0 - ~/.nvm/versions/node/v18.14.2/bin/npm
Browsers:
Chrome: 113.0.5672.92
Safari: 16.3
Reproduction URL
na
Describe the issue
Using the latest next-auth and next I can't create a production build. I get the following error message:
here:
./node_modules/next-auth/core/init.js:10:14
./node_modules/next-auth/core/lib/csrf-token.js:8:14
./node_modules/next-auth/core/lib/email/signin.js:8:14
./node_modules/next-auth/core/lib/utils.js:10:14
./node_modules/oauth/lib/oauth.js:1:12
package json:
next.config.js:
How to reproduce
See above
Expected behavior
It should compile.
The text was updated successfully, but these errors were encountered: