Solution skill
@prisma/client did not initialize yet. please run "prisma generate" and try to import it again.
Complete solution
Fixes @prisma/client did not initialize yet. please run "prisma generate" and try to import it again. The error means the generated Prisma Client was never produced in this environment. Run npx prisma generate in the build (postinstall hook plus an explicit build step), not just on your laptop, then redeploy. Use when the app crashes on startup with this exact message after a fresh install, npm ci, Docker build, or deploy.
TL;DR
@prisma/client did not initialize yet. please run "prisma generate" and try to import it again. means the generated Prisma Client code was never produced in the environment that is crashing. 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. @prisma/client ships as a thin stub; the real client is generated per schema at install or build time.
error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.Use this when
- The exact runtime message is @prisma/client did not initialize yet on a fresh install, CI build, or deploy
- The app works on your machine but crashes on the server with this error
- The crash started right after npm ci, a clean Docker build, or a platform redeploy
Not for this skill when
- prisma generate itself fails: that is a schema or network problem, fix that first
- You get this only in tests: check that your test setup installs dev dependencies and runs generate
- The error names the datasource or a missing config property: that is a Prisma config problem, not a missing generated client
Steps
- Reproduce locally to confirm the diagnosis. Delete the generated client and reinstall:
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 in this environment.
- 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 build logs Generated Prisma Client with 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 Client before the app starts.
- Redeploy and watch the boot logs.
Expected: no init error; the app reaches listening / ready state and serves requests.
Variant phrasings
prisma client did not initialize yet after deploy
The deploy-only version of this error: dependencies installed on the platform but generate was never in the platform build command. Step 3 is the fix.
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 (step 2).
monorepo: generate ran in the wrong package
Run generate in the package that owns schema.prisma, or pass the schema path explicitly with the generate command's schema flag.
Root cause
@prisma/client ships as a thin stub; the real query engine bindings and the typed client are produced by prisma generate at install or build time. Fresh installs, npm ci, and clean Docker builds all start without those generated files, and most deploy pipelines never run generate, so the stub is what the runtime finds.
Edge cases
- If your start command runs generate but the platform caches node_modules between deploys, stale generated files can linger; make generate unconditional in the build.
- 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 that version's documented import, but the generate step is still the fix.
Tool compatibility
Prisma Client 4.x, 5.x, 6.x (generate step unchanged in 7). npm, pnpm, yarn, bun. Hosted deploys on Render, Railway, Vercel, and Docker.
Related skills
- Prisma 7 breaking changes to Prisma config file, and prisma schema: https://vectle.com/skills/sklbiwQKcbojc8jhEJxWJKcg
- ModuleNotFoundError: No module named 'socks' (the same missing-generated-or-optional-piece shape, in Python): https://vectle.com/skills/sklFlB19WyD4leM499zch4jQ
Provenance
Built from a documented Express + TypeScript + Prisma deploy failure and fix, linked in the evidence.
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 2 · 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>