Description
Environment
System:
OS: Linux 6.8 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
CPU: (8) x64 Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
Memory: 22.17 GB / 31.28 GB
Container: Yes
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 20.10.0 - ~/.nvm/versions/node/v20.10.0/bin/node
Yarn: 1.22.22 - ~/.nvm/versions/node/v20.10.0/bin/yarn
npm: 10.2.3 - ~/.nvm/versions/node/v20.10.0/bin/npm
pnpm: 9.7.1 - ~/.nvm/versions/node/v20.10.0/bin/pnpm
Browsers:
Chromium: 135.0.7049.84
npmPackages:
@auth/prisma-adapter: ^2.8.0 => 2.8.0
@neondatabase/serverless: ^1.0.0 => 1.0.0
next: 15.3.0 => 15.3.0
next-auth: ^5.0.0-beta.25 => 5.0.0-beta.25
prisma: ^6.6.0 => 6.6.0
react: ^19.0.0 => 19.1.0
Reproduction URL
https://github.com/tremby/auth-test
Describe the issue
I'm trying to get Nextjs, Authjs/next-auth and its middleware, Prisma, and Neon all working together.
I understand that getting databases to work in edge runtimes is tricky, but the docs say that it is supported with various drivers including the Neon serverless one. I'm using Neon, so that sounds OK to me.
The documentation is difficult to follow, since it boots me off to the Prisma site, and also to the Neon site, and each one seems to give slightly different instructions.
I've done my best to follow the instructions. The most straightforward route through the docs which looks to my eye like it ought to be complete is included in the reproduction repo. Step through its commits and see the messages for details. Not included in the reproduction repo, I also tried various different versions and combinations of the instructions, anything I could find.
With every iteration, when running npm run dev
and navigating to localhost:3000
I see a stack trace, and in the console I have a lot of these:
⨯ [Error: Failed to load external module node:module: ReferenceError: Cannot access 'require' before initialization]
How to reproduce
- Check out the reproduction repo
npm install
cp .env.example .env
vim .env
and fill in valuesnpx prisma generate
npm run dev
- Navigate to
localhost:3000
- See stack trace and console output
Expected behavior
Middleware executes successfully. Page loads. No errors.