This error is very common with Prisma, and it means the Prisma Client was not generated
First, check if both required Prisma packages are properly installed in your project:
npm ls @prisma/client prisma
You should see both packages listed. If either is missing, install them:
npm install @prisma/client
npm install prisma --save-dev
Why both packages?
- @prisma/client - The runtime client you import in your code
- Prisma: The CLI tool used for migrations and generating the client
Prisma requires a schema file at a specific location. Check that you have a file at:
your-project/
├── prisma/
│ └── schema.prisma
├── node_modules/
├── package.json
└── index.js
Your schema.prisma file must contain the client generator configuration:
generator client {
provider = "prisma-client-js"
}
If you don't have this file, initialize Prisma:
npx prisma init
Run migration (recommended).
npx prisma migrate dev --name init
This is where many developers make mistakes. Ensure you're importing Prisma Client correctly in your code
Correct:
const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();
Top comments (0)