Fix Prisma Client Not Found – 'PrismaClient' is Not a Constructor
DodaTech
Updated 2026-06-24
2 min read
In this tutorial, you'll learn about Fix Prisma Client Not Found. We cover key concepts, practical examples, and best practices.
You import PrismaClient in your application code, and get: "PrismaClient is not a constructor" — or "Cannot find module '@prisma/client'". The schema is defined, but the client wasn't generated.
Wrong ❌
// server.js
const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient(); // TypeError: PrismaClient is not a constructor
Or:
Error: Cannot find module '@prisma/client'
You installed `prisma` but forgot `@prisma/client`. Or you generated the client but then changed the schema without re‑generating.
## Right ✅
```bash
# Install both prisma (dev) and @prisma/client (runtime)
npm install prisma --save-dev
npm install @prisma/client
```prisma
// schema.prisma
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
email String @unique
name String?
}
```bash
# Generate the client
npx prisma generate
```javascript
// server.js
const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();
async function main() {
const user = await prisma.user.create({
data: { email: 'alice@example.com', name: 'Alice' },
});
console.log('Created:', user.id);
}
main()
.catch(console.error)
.finally(() => prisma.$disconnect());
**Auto‑generate on every schema change:**
```json
// package.json
{
"scripts": {
"postinstall": "prisma generate",
"dev": "nodemon --watch schema.prisma --exec \"prisma generate && node server.js\""
}
}
**Fix missing `@prisma/client` in CI/CD:**
```yaml
# .github/workflows/deploy.yml
- run: npm ci
- run: npx prisma generate
- run: npm run build
**If the client is generated but still not found:**
Check the `output` path in the generator:
```prisma
generator client {
provider = "prisma-client-js"
output = "../node_modules/.prisma/client" // default
}
If you changed the `output`, update your import path accordingly:
```javascript
const { PrismaClient } = require('./node_modules/.prisma/client');
**Rebuild after Prisma version upgrade:**
```bash
npm install @prisma/client@latest
npx prisma generate
## Root Cause
`PrismaClient` is generated code. It's not shipped with the `prisma` CLI package — it's in `@prisma/client`. After every schema change, `prisma generate` must be re‑run to produce an up‑to‑date client.
## Prevention
- Add `prisma generate` to the `postinstall` script in package.json.
- Run `prisma generate` after every schema change.
- Use `nodemon` or `ts-node-dev` to watch `schema.prisma` and auto‑generate.
- In CI, always run `prisma generate` before building the application.
## Common Mistakes with client not found
1. **Overlapping type class instances that cause GHC to reject the program with ambiguous dispatch errors**
2. **Non-exhaustive pattern matches that compile with warnings then crash at runtime**
3. **Misunderstanding that `String` is `[Char]` with poor performance for large text operations**
These mistakes appear frequently in real-world PRISMA code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
## Practice Exercise
**Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.**
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
## FAQ
<details style="margin-bottom:12px;border:1px solid #e2e8f0;border-radius:10px;overflow:hidden"><summary style="cursor:pointer;padding:14px 18px;font-weight:600;font-size:1.05rem;background:#f8fafc;border-bottom:1px solid #e2e8f0;color:#1e293b">**Q: Can I use Prisma Client without `prisma generate`?**</summary><div style="padding:14px 18px;color:#475569;line-height:1.7;background:#fff"><p>A: No — the client must be generated from the schema. The binary is in <code>node_modules/.prisma/client/</code>.</p>
</div></details><details style="margin-bottom:12px;border:1px solid #e2e8f0;border-radius:10px;overflow:hidden"><summary style="cursor:pointer;padding:14px 18px;font-weight:600;font-size:1.05rem;background:#f8fafc;border-bottom:1px solid #e2e8f0;color:#1e293b">**Q: What's the difference between `prisma` and `@prisma/client`?**</summary><div style="padding:14px 18px;color:#475569;line-height:1.7;background:#fff"><p>A: <code>prisma</code> is the CLI (migrations, generate, studio). <code>@prisma/client</code> is the runtime client library.</p>
</div></details><details style="margin-bottom:12px;border:1px solid #e2e8f0;border-radius:10px;overflow:hidden"><summary style="cursor:pointer;padding:14px 18px;font-weight:600;font-size:1.05rem;background:#f8fafc;border-bottom:1px solid #e2e8f0;color:#1e293b">**Q: Should I commit the generated client to Git?**</summary><div style="padding:14px 18px;color:#475569;line-height:1.7;background:#fff"><p>A: No — add <code>node_modules/</code> and <code>prisma/generated/</code> to <code>.gitignore</code>. Each developer generates it locally.</p>
</div></details><details style="margin-bottom:12px;border:1px solid #e2e8f0;border-radius:10px;overflow:hidden"><summary style="cursor:pointer;padding:14px 18px;font-weight:600;font-size:1.05rem;background:#f8fafc;border-bottom:1px solid #e2e8f0;color:#1e293b">**Q: How do I regenerate the client for a specific schema?**</summary><div style="padding:14px 18px;color:#475569;line-height:1.7;background:#fff"><p>A: <code>npx prisma generate --schema=path/to/schema.prisma</code>.</p>
</div></details>
---
*Prisma Client setup is covered in the [DodaTech Prisma Fundamentals course](https://dodatech.com/courses/prisma).*
← Previous
How to Fix Prettier Not Formatting in VS Code
Next →
Fix Prisma Datasource URL – Connection String Issues
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro