Skip to content

Prisma adapter does not work with custom output path #13060

Open
@karl-barbour

Description

@karl-barbour

Adapter type

@auth/prisma-adapter

Environment

  System:
    OS: macOS 15.5
    CPU: (12) arm64 Apple M4 Pro
    Memory: 4.41 GB / 48.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.16.0 - ~/.nvm/versions/node/v22.16.0/bin/node
    npm: 11.4.1 - ~/.nvm/versions/node/v22.16.0/bin/npm
    pnpm: 10.11.1 - ~/.nvm/versions/node/v22.16.0/bin/pnpm
  Browsers:
    Chrome: 137.0.7151.120
    Edge: 137.0.3296.83
    Safari: 18.5
  npmPackages:
    @auth/prisma-adapter: ^2.9.1 => 2.9.1 
    @auth/unstorage-adapter: ^2.0.0 => 2.9.1 
    next: latest => 15.3.4 
    next-auth: beta => 5.0.0-beta.28 
    react: ^18.2.0 => 18.3.1 

Reproduction URL

https://github.com/karl-barbour/prisma-adapter-bug

Describe the issue

As per the closed issue #13035 raised by @Stadly

The Prisma adapter imports from @prisma/client. This does not work when using a custom output path in the Prisma generator.

Prisma strongly recommends using a custom output path. Not doing so results in a warning in version 6.6.0, and it will be required in version 7. Also, the new prisma-client generator requires a custom output path.

How to reproduce

Create a schema with a custom Prisma output path.

prisma/schema.prisma

...

generator client {
  provider = "prisma-client-js"
  output = "./generated/client"
}

...

(This repo uses GitHub as a provider)

  1. Generate client: pnpm prisma generate (will need pnpm prisma migrate dev if empty database)
  2. Run next: pnpm dev
  3. Browse to http://localhost:3000
  4. Receive error:
> @ dev /Users/Karl.Barbour/git/prisma-adapter-bug
> next

   ▲ Next.js 15.3.4
   - Local:        http://localhost:3000
   - Network:      http://10.4.82.149:3000
   - Environments: .env

 ✓ Starting...
 ✓ Ready in 1241ms
 ⨯ ./node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@prisma/client/default.js:2:1
Module not found: Can't resolve '.prisma/client/default'
  1 | module.exports = {
> 2 |   ...require('.prisma/client/default'),
    | ^
  3 | }
  4 |

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]__typesc_bbc972bb237e83a96bb1b898008cba97/node_modules/@auth/prisma-adapter/index.js
./auth.ts
./middleware.ts
 ⨯ ./node_modules/.pnpm/@[email protected][email protected][email protected][email protected]/node_modules/@prisma/client/default.js:2:1
Module not found: Can't resolve '.prisma/client/default'
  1 | module.exports = {
> 2 |   ...require('.prisma/client/default'),
    | ^
  3 | }
  4 |

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]__typesc_bbc972bb237e83a96bb1b898008cba97/node_modules/@auth/prisma-adapter/index.js
./auth.ts
./middleware.ts
 ○ Compiling /middleware ...
 ✓ Compiled /_error in 246ms (360 modules)
 GET / 404 in 2ms
 ○ Compiling /favicon.ico ...
 ✓ Compiled /favicon.ico in 1238ms (1525 modules)
 ✓ Compiled in 166ms (1511 modules)

Expected behavior

Auth.js should not import Prisma and PrismaClient from @prisma/client.

Metadata

Metadata

Assignees

No one assigned

    Labels

    adaptersChanges related to the core code concerning database adaptersbugSomething isn't workingtriageUnseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions