Error: @prisma/client did not initialize yet. Please run "prisma generate"
Quick answer
Run `npx prisma generate` to regenerate the Prisma Client after changing your schema, after a fresh `npm install`, or after pulling changes from git — the generated client isn't committed to your repo by default.
What causes this error
Prisma Client is code-generated from your `schema.prisma` file into `node_modules/.prisma/client`. Since that's inside `node_modules`, it's gitignored by default — so a fresh clone, a fresh `npm install`, or a schema change without regenerating will leave you with an outdated or missing client.
The Fix
npx prisma generateAdd it as a `postinstall` script so it happens automatically:
// package.json
"scripts": {
"postinstall": "prisma generate"
}Common causes / variations
- Cloning the repo fresh and running `npm install` without a postinstall hook
- Editing `schema.prisma` and forgetting to regenerate before restarting the dev server
- Deploying to a platform that caches `node_modules` and skips a clean install
Related errors
See also: PrismaClientInitializationError.
Was this fix helpful?
Comments
Loading comments...