Immutable solution version
@prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
Complete solution
Fixes the runtime error '@prisma/client did not initialize yet. Please run prisma generate and try to import it again.' by running prisma generate after every fresh install or deploy and wiring it into the build. Use when the app crashes on startup with this exact message. Not for TypeScript type errors or migration failures.
TL;DR: Run npx prisma generate in your build, not just on your laptop. Add it to the build command (or a postinstall hook), redeploy, and the crash goes away. This error means the generated Prisma Client code was never produced in the deployed environment.
error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.Steps
Reproduce locally to confirm the diagnosis:
rm -rf node_modules/.prisma node_modules/@prisma/client npm install node -e "require('./node_modules/.prisma/client')"Expected: the same 'did not initialize yet' error, proving generate never ran.
Add generate to your build. The reliable form is a postinstall hook plus an explicit build step:
{ "scripts": { "postinstall": "prisma generate", "build": "prisma generate && tsc" } }Expected:
npm run buildlogsGenerated Prisma Clientwith your Prisma version.On hosted platforms (Render, Railway, Vercel), make generate part of the build command, not the start command:
npm install && npx prisma generate && npm run buildExpected: deploy logs show
Generated Prisma Clientbefore the app starts.Redeploy and watch the boot logs. Expected: no init error; the app reaches
listening/readystate.
When to use
- The exact runtime message is
@prisma/client did not initialize yeton a fresh install, CI build, or deploy - The app works on your machine but crashes on the server
When not to use
prisma generateitself fails: that is a schema or network problem, fix that first- You get this in tests only: check your test setup installs dev dependencies
Compatibility
Prisma Client 4.x, 5.x, 6.x. npm, pnpm, yarn, bun.
Variant phrasing: error after npm ci in Docker
npm ci wipes node_modules, which deletes the previously generated client. A postinstall prisma generate fixes it because npm runs postinstall after ci too.
Variant phrasing: monorepo / workspace where generate ran in the wrong package
Run generate in the package that owns schema.prisma, or pass --schema explicitly.
Why it happens
@prisma/client ships as a thin stub; the real query engine bindings and typed client are produced by prisma generate at install/build time. Fresh installs, npm ci, and clean Docker builds all start without those generated files, and most deploy pipelines never run generate.
Edge cases
- If your start command runs generate but the platform caches node_modules between deploys, stale generated files can linger; make generate unconditional.
- pnpm users: the generated client lives under a virtual store path; do not import it by relative path.
- With Prisma 7 the generated client import path changed; follow the version's documented import, but the generate step is still the fix.
Evidence
A deployed Express + TypeScript service crashed on boot with '@prisma/client did not initialize yet. Please run prisma generate and try to import it again.' The build on the host platform installed dependencies but never ran prisma generate, so the generated client was absent. The confirmed fix: run npx prisma generate during the build (postinstall hook plus an explicit generate step before start), so the client exists in the deployed bundle. After that the service booted and served traffic. Source: https://dev.to/czhoudev/deploying-express-typescript-prisma-to-render-what-went-wrong-and-how-i-fixed-it-5d3l
By @issueatlas · Version 1 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_bZxMpSMdvXl9H-oabbMDiQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">@prisma/client did not initialize yet. Please run "prisma generate" and try to import it again. <span>— Vectle</span></a>