Skip to content

[6.7.0] NextJS - Prisma #27079

Open
Open

Description

@devpanda0

Bug description

See bug. It occurs directly at startup

Severity

🚨 Critical: Data loss, app crash, security issue

Reproduction

https://github.com/devpanda0/prisma-nextjs-repro

pull the repo, install packages, generate Prisma files, then run next dev --turbo

Expected vs. Actual Behavior

fix it

Frequency

Consistently reproducible

Does this occur in development or production?

Both development and production

Is this a regression?

The error has been occurring since switching to “Rust free”

Workaround

No workaround found

Prisma Schema & Queries

generator client {
  provider        = "prisma-client"
  output          = "../src/prisma"
  previewFeatures = ["queryCompiler", "driverAdapters"]
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model User {
  id                    String   @id @default(cuid(2))
  discordId             String   @unique
  username              String
  logoUrl               String
  currentOrganizationId String?
  guildIds              String[] @default([])
  createdAt             DateTime @default(now())
  updatedAt             DateTime @updatedAt

  // Better-auth Felder
  email         String? @unique
  emailVerified Boolean @default(false)
  image         String? // Könnte logoUrl verwenden

  sessions Session[]
  accounts Account[]

  @@index([id, discordId])
}

model Session {
  id        String   @id
  expiresAt DateTime
  token     String
  createdAt DateTime
  updatedAt DateTime
  ipAddress String?
  userAgent String?
  userId    String
  user      User     @relation(fields: [userId], references: [id], onDelete: Cascade)

  @@unique([token])
  @@map("session")
}

model Account {
  id                    String    @id
  accountId             String
  providerId            String
  userId                String
  user                  User      @relation(fields: [userId], references: [id], onDelete: Cascade)
  accessToken           String?
  refreshToken          String?
  idToken               String?
  accessTokenExpiresAt  DateTime?
  refreshTokenExpiresAt DateTime?
  scope                 String?
  password              String?
  createdAt             DateTime
  updatedAt             DateTime

  @@map("account")
}

model Verification {
  id         String    @id
  identifier String
  value      String
  expiresAt  DateTime
  createdAt  DateTime?
  updatedAt  DateTime?

  @@map("verification")
}

Prisma Config

import 'dotenv/config';
import path from 'node:path';
import { defineConfig } from 'prisma/config';

export default defineConfig({
  earlyAccess: true,
  schema: path.join('prisma'),
});

Logs & Debug Info

> next dev --turbo

   ▲ Next.js 15.3.1 (Turbopack)
   - Local:        http://localhost:3000
   - Network:      http://10.8.3.10:3000
   - Environments: .env

 ✓ Starting...
 ✓ Ready in 1657ms
 ○ Compiling / ...
 ✓ Compiled / in 3.4s
 ⨯ ./src/prisma/client.ts:14:1
Module not found: Can't resolve './enums.js'
  12 |
  13 | import * as runtime from "@prisma/client/runtime/wasm"
> 14 | import * as $Enums from "./enums.js"
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  15 | import * as $Class from "./internal/class.js"
  16 | import * as Prisma from "./internal/prismaNamespace.js"
  17 |



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



./src/prisma/client.ts:18:1
Module not found: Can't resolve './enums.js'
  16 | import * as Prisma from "./internal/prismaNamespace.js"
  17 |
> 18 | export * as $Enums from './enums.js'
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  19 | /**
  20 |  * ## Prisma Client
  21 |  *



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



./src/prisma/client.ts:15:1
Module not found: Can't resolve './internal/class.js'
  13 | import * as runtime from "@prisma/client/runtime/wasm"
  14 | import * as $Enums from "./enums.js"
> 15 | import * as $Class from "./internal/class.js"
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  16 | import * as Prisma from "./internal/prismaNamespace.js"
  17 |
  18 | export * as $Enums from './enums.js'



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



./src/prisma/client.ts:16:1
Module not found: Can't resolve './internal/prismaNamespace.js'
  14 | import * as $Enums from "./enums.js"
  15 | import * as $Class from "./internal/class.js"
> 16 | import * as Prisma from "./internal/prismaNamespace.js"
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  17 |
  18 | export * as $Enums from './enums.js'
  19 | /**



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


 ○ Compiling /_error ...
 ✓ Compiled /_error in 1157ms
 GET / 500 in 5013ms

Environment & Setup

  • OS: Windows
  • Database: PostgreSQL
  • Node.js version: v22.14.0

Prisma Version

Loaded Prisma config from "F:\Aufträge\test\prisma.config.ts".
Prisma config detected, skipping environment variable loading.
Prisma schema loaded from prisma
prisma                  : 6.7.0
@prisma/client          : 6.7.0
Computed binaryTarget   : windows
Operating System        : win32
Architecture            : x64
Node.js                 : v22.14.0
TypeScript              : 5.8.3
Query Engine (Node-API) : libquery-engine 3cff47a7f5d65c3ea74883f1d736e41d68ce91ed (at node_modules\@prisma\engines\query_engine-windows.dll.node)
Schema Engine           : schema-engine-cli 3cff47a7f5d65c3ea74883f1d736e41d68ce91ed (at node_modules\@prisma\engines\schema-engine-windows.exe)
Schema Wasm             : @prisma/prisma-schema-wasm 6.7.0-36.3cff47a7f5d65c3ea74883f1d736e41d68ce91ed
Default Engines Hash    : 3cff47a7f5d65c3ea74883f1d736e41d68ce91ed
Studio                  : 0.511.0
Preview Features        : driverAdapters, queryCompile

Activity

  1. added
    kind/bug
    on May 4, 2025
  2. devpanda0 commented on May 6, 2025

    @devpanda0
    Author

    maybe any news? Can anyone reproduce the error?

  3. djshubs commented on May 7, 2025

    @djshubs

    I'm getting a similar error.

  4. added
    topic: prisma generate
    bug/1-unconfirmed
    on May 8, 2025
  5. FGoessler commented on May 8, 2025

    @FGoessler
    Contributor

    Hey @devpanda0 👋

    It seems you are using the new generator which is currently in preview (provider = "prisma-client").

    I think we have fix for this particular issue coming up that will fix the used file extension in the generated output.
    Can you try out a recent dev build like 6.8.0-dev.24 please?
    Alternatively you can manually configure the used file extension by setting generatedFileExtension = "ts in the generator block.

    You should also be able to work around this by using our old generator (provider = "prisma-client-js") for now.

  6. devpanda0 commented on May 8, 2025

    @devpanda0
    Author

    Hey @devpanda0 👋

    It seems you are using the new generator which is currently in preview (provider = "prisma-client").

    I think we have fix for this particular issue coming up that will fix the used file extension in the generated output.
    Can you try out a recent dev build like 6.8.0-dev.24 please?
    Alternatively you can manually configure the used file extension by setting generatedFileExtension = "ts in the generator block.

    You should also be able to work around this by using our old generator (provider = "prisma-client-js") for now.

    Hey, I’ll try it out and give you some feedback. Thanks for your reply! :)

  7. devpanda0 commented on May 8, 2025

    @devpanda0
    Author

    okay, its works now but not more in the middleware
    @FGoessler

  8. FGoessler commented on May 14, 2025

    @FGoessler
    Contributor

    What do you mean by "not more in the middleware" @devpanda0 ? 🤔

  9. devpanda0 commented on May 14, 2025

    @devpanda0
    Author

    @FGoessler
    ⚠ ./generated/prisma/internal/class.ts:79:32
    Ecmascript file had an error
    77 |
    78 | getQueryCompilerWasmModule: async () => {

    79 | const { readFile } = await import('node:fs/promises')
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^
    80 | const { createRequire } = await import('node:module')
    81 | const require = createRequire(import.meta.url)

    ⚠ ./generated/prisma/internal/class.ts:80:37
    Ecmascript file had an error
    78 | getQueryCompilerWasmModule: async () => {
    79 | const { readFile } = await import('node:fs/promises')

    80 | const { createRequire } = await import('node:module')
    | ^^^^^^^^^^^^^^^^^^^^^
    81 | const require = createRequire(import.meta.url)
    82 |
    83 | const wasmModulePath = require.resolve("@prisma/client/runtime/query_compiler_bg.postgresql.wasm")

    ⚠ ./generated/prisma/client.ts:13:1
    Ecmascript file had an error
    11 | import * as process from 'node:process'
    12 | import * as path from 'node:path'

    13 | import { fileURLToPath } from 'node:url'
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    14 | const __dirname = path.dirname(fileURLToPath(import.meta.url))
    15 |
    16 | import * as runtime from "@prisma/client/runtime/client"

  10. devpanda0 commented on May 14, 2025

    @devpanda0
    Author

    Tested with 6.8.0-dev.46 @FGoessler

  11. devpanda0 commented on May 16, 2025

    @devpanda0
    Author

    Tested with 6.9.0-dev.3 same problem as above. i don't know why :( @FGoessler

  12. devpanda0 commented on May 16, 2025

    @devpanda0
    Author

    When i use the runtime "edge-light" i got this error:

    ⚠ ./generated/prisma/internal
    Package @prisma/client can't be external
    The request @prisma/client/runtime/query_engine_bg.postgresql.wasm matches serverExternalPackages (or the default list).
    Only .mjs, .cjs, .js, .json, or .node can be handled by Node.js.

  13. 12 remaining items

  14. hanhn-dev commented on Nov 22, 2025

    @hanhn-dev

    I got the same issue and I solved it with my changes as following. I added moduleFormat, generatedFileExtension and importFileExtension. One thing to note that I added them after migrating from v6 to v7.

    generator client {
      provider = "prisma-client"
      output   = "../generated/prisma"
      moduleFormat = "esm"
      generatedFileExtension = "ts"
      importFileExtension = "ts"
    }
    
  15. mosespace commented on Nov 24, 2025

    @mosespace

    I got the same issue and I solved it with my changes as following. I added moduleFormat, generatedFileExtension and importFileExtension. One thing to note that I added them after migrating from v6 to v7.

    generator client {
      provider = "prisma-client"
      output   = "../generated/prisma"
      moduleFormat = "esm"
      generatedFileExtension = "ts"
      importFileExtension = "ts"
    }
    

    🔥 I also admit after adding the following, it was fixed. Using Nextjs 16.0.3 and Prisma Version 7

  16. jdhenry08 commented on Nov 24, 2025

    @jdhenry08

    I got the same issue and I solved it with my changes as following. I added moduleFormat, generatedFileExtension and importFileExtension. One thing to note that I added them after migrating from v6 to v7.

    generator client {
      provider = "prisma-client"
      output   = "../generated/prisma"
      moduleFormat = "esm"
      generatedFileExtension = "ts"
      importFileExtension = "ts"
    }
    

    This DID NOT work for me on [email protected].

  17. nishatislam04 commented on Nov 27, 2025

    @nishatislam04

    after implementing the guide from @hanhn-dev at latest nextjs v16.0.5 the js importing error resolved.
    when i first faced it, i was very lost. and had a hard time googling this issue
    i hope prisma fix this issue either in built-in or add the support on the official prisma docs.

    edit: i am using prisma v7.0.1

  18. jcubic commented on Nov 29, 2025

    @jcubic

    I just tested again. I have two databases. Adding the below code to both schema files fixed the issue. Even before upgrading to 7.0.1.

      moduleFormat = "esm"
      generatedFileExtension = "ts"
      importFileExtension = "ts"
    
  19. lexmin0412 commented on Jan 7, 2026

    @lexmin0412

    Same Problem with Next.js when upgrade from v6, resolved with:

    generator client {
      ...
      generatedFileExtension = "ts"
      importFileExtension = "ts"
    }
  20. dfodeker commented on Jan 7, 2026

    @dfodeker

    I ran into the same issue while upgrading Next.js 16.0.3 and migrating Prisma from v6.6.0 → v7.2.0.

    The first thing I did was delete the existing ./generated/prisma folder . ( probably not necessary )

    After that, I was able to fix it in a couple different ways.


    Option 1: Node-style resolution (changes generated imports)

    When I set Node ESM settings in tsconfig.json:

    {
      "compilerOptions": {
        "module": "nodenext",
        "moduleResolution": "nodenext"
      }
    } 
    

    and updated the prisma generator

    generator client {
      moduleFormat = "esm"
      generatedFileExtension = "ts"
      importFileExtension = "ts"
    }

    This caused the generated client to use .ts imports instead of .js, and the build passed. I personally could not get the generator setting to work with node as my module resolution


    Option 2: Bundler-style resolution

    Changing TypeScript to bundler resolution also fixed it, even though the Prisma docs recommend "moduleResolution": "node"

    {
      "compilerOptions": {
        "module": "esnext",
        "moduleResolution": "bundler"
      }
    }

    Then running bun prisma generate / npm prisma generate worked without further changes. Hopefully this helps someone else upgrading.

  21. devnchill commented on Jan 14, 2026

    @devnchill

    still encountering this problem . i did required changes in schema.prisma as other mentioned above , that doesn't seems to fix it. Using turborepo .

    "prisma": "^7.2.0"
    
  22. iammdsameer commented on Jan 15, 2026

    @iammdsameer

    Here’s what worked for me in my Next.js app with prisma@^7.2.0, in case anyone else runs into the same issue:

    1. Remove the entire generated/ directory (this folder is created after running npx prisma generate).

    2. Update tsconfig.json

      • Set the module resolution strategy to:
        {
          "moduleResolution": "bundler"
        }
    3. Regenerate the Prisma client

      npx prisma generate
      

    After doing the above, everything started working as expected.
    It seems the issue was caused by stale generated files combined with an incompatible moduleResolution setting.

  23. added a commit that references this issue on Jan 20, 2026
  24. geneshairzan commented on Jan 30, 2026

    @geneshairzan
    generator client {
    ...
      generatedFileExtension = "ts" // THIS LINE SAVE THE DAY
      importFileExtension = "ts" // THIS LINE SAVE THE DAY
    
  25. nxtvoid commented on Apr 22, 2026

    @nxtvoid

    i ran into this issue today on Turborepo

    "prisma": "7.7.0"
    "next": "16.2.4"
    "turbo": "2.8.17"

    what @hanhn-dev mentioned solved this problem for me

    generator client {
      provider               = "prisma-client"
      output                 = "../generated/prisma"
      moduleFormat           = "esm"
      generatedFileExtension = "ts"
      importFileExtension    = "ts"
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug/1-unconfirmedkind/bugtopic: generator-tstopic: prisma generate

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions