Skip to content
Latchkey

Prisma "Cannot find module '.prisma/client'" in CI

Node resolved @prisma/client but that package re-exports code from .prisma/client, the folder prisma generate writes. When generate has not run, that folder is absent and the require fails outright.

What this error means

The app crashes at startup with "Error: Cannot find module '.prisma/client'" or "Cannot find module '@prisma/client/runtime'", usually right after a clean install in CI.

Prisma
Error: Cannot find module '.prisma/client'
Require stack:
- /app/node_modules/@prisma/client/default.js

Common causes

prisma generate never wrote the output

The .prisma/client directory is created by generation. A build that skips prisma generate has nothing there to require.

A custom generator output path is not present

If generator client { output = "..." } points elsewhere, the default .prisma/client location will be empty and the require path is wrong.

How to fix it

Generate the client before running

  1. Run npx prisma generate after installing dependencies.
  2. Confirm node_modules/.prisma/client now exists.
  3. Then run the build, tests, or app.
Terminal
npm ci
npx prisma generate
node dist/main.js

Point imports at a custom output path

If you set a custom generator output, import from that path and generate to it explicitly.

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

How to prevent it

  • Always run generate after install and before build in CI.
  • Keep the generator output consistent with your import paths.
  • Do not commit node_modules and expect the generated client to survive.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →