P
Prisma2mo ago
Amine,

upgrading from v5 to v6

Hi, hope whoever reads this is doing good. I got this Prisma error after upgrading from v5 to v6. The reason I upgraded is because I wanted to split my big schema into multiple .prisma files inside a /models folder. That part works fine — but the problem is that the new Prisma version doesn’t generate the client in node_modules anymore. So I added this in my generator:
output = "../generated/client"
output = "../generated/client"
Now the client gets generated, but it looks like Prisma combines all my schema files into one big schema, and then it throws this error:
The generator "client" cannot be defined because a generator with that name already exists.
The generator "client" cannot be defined because a generator with that name already exists.
After that, when I try to use the generated client in my Node app, I get this error:
Error: Cannot find module '../../generated/client'
Require stack:
- /dist/src/prisma/prisma.service.js
- /dist/src/app.controller.js
- /dist/src/app.module.js
- /dist/src/main.js
Error: Cannot find module '../../generated/client'
Require stack:
- /dist/src/prisma/prisma.service.js
- /dist/src/app.controller.js
- /dist/src/app.module.js
- /dist/src/main.js
Not sure why, but it also affects my migrations. When I run a migration, it acts like it’s creating everything from scratch, even though the tables already exist. Not sure if that’s normal in v6 or if I messed something up. Here’s my simple Prisma config file (can’t share full code for confidentiality):
import path from 'node:path'
import type { PrismaConfig } from 'prisma'

export default {
schema: path.join('prisma'),
migrations: {
path: path.join('prisma', 'migrations'),
},
} satisfies PrismaConfig
import path from 'node:path'
import type { PrismaConfig } from 'prisma'

export default {
schema: path.join('prisma'),
migrations: {
path: path.join('prisma', 'migrations'),
},
} satisfies PrismaConfig
So yeah, that’s what’s happening. I just want to know: * is this normal for Prisma v6 when using multi-file schemas? * or is there something I should change so it only generates one client and doesn’t reset migrations? Thanks in advance 🙏
No description
No description
2 Replies
Prisma AI Help
Prisma AI Help2mo ago
You selected the bot's instantaneous insights. Let me compile your answer right away! It’s not normal for Prisma v6 to throw a “generator ... cannot be defined because a generator with that name already exists” error or to reset migrations when using multi-file schemas—these are usually signs of a misconfiguration. Key points to check: 1. Multi-file schema setup:
- Your prisma.config.ts should point to the folder containing all your .prisma files (not just a subfolder). For example, if your structure is:
prisma/
├── migrations/
├── models/
│ ├── user.prisma
│ └── post.prisma
└── schema.prisma

prisma/
├── migrations/
├── models/
│ ├── user.prisma
│ └── post.prisma
└── schema.prisma

Then your config should be:
export default {
schema: path.join('prisma'),
migrations: { path: path.join('prisma', 'migrations') },
} satisfies PrismaConfig

export default {
schema: path.join('prisma'),
migrations: { path: path.join('prisma', 'migrations') },
} satisfies PrismaConfig

This ensures Prisma picks up all schema files recursively, including the main one with your generator and datasource blocks. If you point to just prisma/models, it will miss schema.prisma and cause issues like duplicate generators or missing models [multi-file schema docs]. 2. Generated client import:
- With output = "../generated/client", you should import the client using:
import { PrismaClient } from '../../generated/client'

import { PrismaClient } from '../../generated/client'

Make sure the import path matches your build output structure. If you’re running from dist/, the relative path may differ—double-check your build and import paths [client location docs]. 3. Migrations resetting:
- If migrations are being reset, it’s likely Prisma isn’t seeing your existing models (e.g., due to schema misconfiguration), so it thinks the DB is empty. Ensure all model files are included and the migrations folder is at the same level as the main schema file [ multi-file schema docs]. Summary:
- Point your config’s schema to the parent folder (prisma), not a subfolder. - Ensure only one generator block exists across all schema files. - Double-check your import paths after build. - The issues you’re seeing are not expected in v6 and are likely due to the above misconfigurations. Let me know if you need more help!
Nurul
Nurul2mo ago
Was the Bot response helpful?

Did you find this page helpful?