Prisma + NestJS import issue when using custom client output
When using a custom Prisma Client output directory inside a NestJS project, the generated client cannot be imported correctly ā even though the files exist and Prisma successfully generates them.
Error: Cannot find module '../../../prisma/generated/prisma'
Require stack:
- dist/src/libs/prisma/prisma.service.js
- dist/src/libs/prisma/prisma.module.js
- dist/src/app.module.js
- dist/src/main.js
version: "prisma": "^6.17.1",


2 Replies
You selected the bot's instantaneous insights. Let me compile your answer right away!
This is a common issue when using custom Prisma Client output paths in NestJS. The generated client files exist but aren't being copied to the
dist folder during the build process.
Solutions
1. Configure NestJS to Copy Generated Files
Modify your nest-cli.json to include the generated folder as assets:
Adjust the include path based on where your generated client is located relative to your source root. NestJS custom output path issue
2. Exclude Prisma Folder from Build
If you have a seed.ts file in your prisma folder, it can affect the dist structure. Exclude it in tsconfig.build.json:
Seed file issue
3. Alternative: Generate Outside Prisma Folder
Generate the client outside the prisma directory or at the project root, which gets picked up more reliably by NestJS bundlers. Output path location
Important Note
When using custom output, you must import from the generated path, not from @prisma/client:
Custom output import requirement
š¤ Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly.
In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.How have you aliased
generated?
What happens if you try importing from ../../generated/prisma in prisma.service.ts?