nextauthjs / nextauthjs/next-auth

@auth/prisma-adapter creating error on import line at auth.ts

Open
#12,913 3 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

adapters bug triage
Dominant language
TypeScript
Stars
28.4k
Forks
4k
PR merge metrics
No merged PRs in 30d

Description

Adapter type

@auth/prisma-adapter

Environment
  System:
    OS: Windows 11 10.0.26100
    CPU: (16) x64 13th Gen Intel(R) Core(TM) i5-1340P
    Memory: 2.26 GB / 15.56 GB
  Binaries:
    Node: 20.12.2 - C:\Program Files\nodejs\node.EXE
    npm: 10.8.2 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.9.0 - ~\AppData\Local\pnpm\pnpm.CMD
    bun: 1.2.7 - ~\.bun\bin\bun.EXE
  Browsers:
    Edge: Chromium (134.0.3124.93)
    Internet Explorer: 11.0.26100.1882
  npmPackages:
    @auth/prisma-adapter: ^2.9.0 => 2.9.0
    next: 15.3.1 => 15.3.1
    next-auth: ^5.0.0-beta.27 => 5.0.0-beta.27
    react: ^19.1.0 => 19.1.0
Reproduction URL

https://github.com/ezeamin/next-auth-test

Describe the issue

When runing bun dev on an empty nextjs 15 project (with prisma and next-auth), it crashes when starting. Happens both with and without turbopack, showing different information about the same error:

With turbo:

⨯ Error: Failed to load external module node:module: ReferenceError: Cannot access 'require' before initialization
    at Object.externalRequire [as x] (.next\server\edge\chunks\edge-wrapper_203abea8.js:1448:15)
    at <unknown> (.next\server\edge\chunks\edge-wrapper_203abea8.js:722:27)
    at runModuleExecutionHooks (.next\server\edge\chunks\edge-wrapper_203abea8.js:768:9)
    at instantiateModule (.next\server\edge\chunks\edge-wrapper_203abea8.js:720:9)
    at getOrInstantiateModuleFromParent (.next\server\edge\chunks\edge-wrapper_203abea8.js:653:12)
    at esmImport (.next\server\edge\chunks\edge-wrapper_203abea8.js:143:20)
    at <unknown> (.next\server\edge\chunks\edge-wrapper_203abea8.js:722:27)
    at runModuleExecutionHooks (.next\server\edge\chunks\edge-wrapper_203abea8.js:768:9)
 ○ Compiling /_not-found/page ...
 ✓ Compiled /_not-found/page in 1388ms

With webpack:

○ Compiling /middleware ...
 ⨯ node:child_process
Module build failed: UnhandledSchemeError: Reading from "node:child_process" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
Import trace for requested module:
node:child_process
./node_modules/@prisma/client/runtime/library.mjs
./node_modules/@auth/prisma-adapter/index.js
./src/auth.ts
<w> [webpack.cache.PackFileCacheStrategy] Serializing big strings (196kiB) impacts deserialization performance (consider using Buffer instead and decode when needed)
 ✓ Compiled /_error in 1584ms (367 modules)

This happens with bun and npm. Tried erasing .next and node_modules folders, using other package managers, without success. Used docker as well to ensure env free errors, but it's also showing the same error.

How to reproduce
  1. Run bun dev
  2. Go to http://localhost:3000
  3. You'll see the error showing on screen.

Image

Expected behavior

To run the app without any problem.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure from the linked project with the reported bun dev and webpack or Turbopack variants, then inspect the src/auth.ts import and the @auth/prisma-adapter and @prisma/client/runtime/library.mjs trace. Done means the empty Next.js 15 app starts and serves its page without the reported import or node: module errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
nextjs, node.js, react, typescript
Domain
authentication, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.