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.
Error: Cannot find module '.prisma/client'
Require stack:
- /app/node_modules/@prisma/client/default.jsCommon 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
- Run
npx prisma generateafter installing dependencies. - Confirm
node_modules/.prisma/clientnow exists. - Then run the build, tests, or app.
npm ci
npx prisma generate
node dist/main.jsPoint imports at a custom output path
If you set a custom generator output, import from that path and generate to it explicitly.
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
outputconsistent with your import paths. - Do not commit node_modules and expect the generated client to survive.