That's what I did in package.json file (It was a deploy a Next app on Versel) I just added generate command to the build script:

"scripts": {
    "dev": "next dev",
    "build": "prisma generate && next build",
    "start": "next start",
    "lint": "next lint"
  },

Not sure if it is a correct way, though..

Answer from maxuapro on Stack Overflow
🌐
Prisma
prisma.io › home › generating prisma client › generating prisma client › generating prisma client › generating prisma client
Generating Prisma Client | Prisma Documentation
In many projects it also makes sense to run prisma generate in postinstall or before your production build so deployments always use a current client.
Discussions

node.js - @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again - Stack Overflow
I address the directory where generated folder is created in prisma folder. ... I was using next js with Prisma and when deploy it to Vercel it showed me this error, I just added "postinstall":"npx prisma generate" in the scripts of package.json file More on stackoverflow.com
🌐 stackoverflow.com
Nextjs vercel deployement prisma issue
I had the same issue and I needed to add a postinstall script to my package.json, that fixed the vercel deployment for me. Try adding: "postinstall": "prisma generate", More on reddit.com
🌐 r/nextjs
13
2
April 5, 2024
Has anyone deployed Prisma recently with NextJS 13?
Add Prisma generate as a post install script More on reddit.com
🌐 r/nextjs
14
2
September 10, 2023
Question: Override default postinstall script - for custom path
I am using NextJS to build my application. When running a build, prisma triggers a postinstall script. However, I use a custom path so this generates a warning. The simplest solution was to add my ... More on github.com
🌐 github.com
2
1
🌐
GitHub
github.com › prisma › web › issues › 3339
docs: prisma generate post install · Issue #3339 · prisma/web
June 28, 2022 - The docs at https://github.com...godb/200-install-prisma-client.mdx states that prisma generate is automatically run after running npm install @primsa/client....
Author   prisma
🌐
Prisma
prisma.io › home › next.js › next.js › next.js › next.js
Comprehensive Guide to Using Prisma ORM with Next.js | Prisma Documentation
Learn how: https://pris.ly/d/vercel-build · This occurs because Vercel caches the dependencies of your project until one of those dependencies changes. Prisma ORM uses a postinstall hook to generate Prisma Client when dependencies are installed.
🌐
Prisma
prisma.io › home › deploy to vercel › deploy to vercel › deploy to vercel › deploy to vercel › deploy to vercel
Deploy to Vercel | Prisma Documentation
Vercel will automatically cache dependencies on deployment. For most applications, this will not cause any issues. However, for Prisma ORM, it may result in an outdated version of Prisma Client on a change in your Prisma schema. To avoid this issue, add prisma generate to the postinstall script of your application:
🌐
Prisma
prisma.io › home › next.js › next.js › next.js
How to use Prisma ORM and Prisma Postgres with Next.js and Vercel | Prisma Documentation
{ "name": "nextjs-prisma", "version": "0.1.0", "private": true, "scripts": { "dev": "next dev --turbopack", "build": "next build", "postinstall": "prisma generate", "start": "next start", "lint": "next lint" }, "prisma": { "seed": "tsx prisma/seed.ts" }, "dependencies": { "@prisma/adapter-pg": "^6.2.1", "@prisma/client": "^6.2.1", "next": "15.1.4", "pg": "^8.13.1", "react": "^19.0.0", "react-dom": "^19.0.0" }, "devDependencies": { "@eslint/eslintrc": "^3", "@types/node": "^20", "@types/react": "^19", "@types/react-dom": "^19", "eslint": "^9", "eslint-config-next": "15.1.4", "postcss": "^8", "prisma": "^6.2.1", "tailwindcss": "^3.4.1", "tsx": "^4.19.2", "typescript": "^5" } }
Top answer
1 of 16
41

Just remove the following line from the schema.prisma file:

output   = "../generated/prisma"

and execute:

npx prisma generate
2 of 16
18

I know that this has been marked as solved, but I just wanted to share my setup for anyone interested.

Dockerfile

# Build image
FROM node:16.13-alpine as builder
WORKDIR /app

# Not sure if you will need this
# RUN apk add --update openssl

COPY package*.json ./
RUN npm ci --quiet

COPY ./prisma prisma
COPY ./src src
RUN npm run build

# Production image

FROM node:16.13-alpine
WORKDIR /app
ENV NODE_ENV production

COPY package*.json ./
RUN npm ci --only=production --quiet

COPY --chown=node:node --from=builder /app/prisma /app/prisma
COPY --chown=node:node --from=builder /app/src /app/src

USER node

EXPOSE 8080
CMD ["node", "src/index.js"]

package.json

{
  "name": "example",
  "description": "",
  "version": "0.1.0",
  "scripts": {
    "generate": "npx prisma generate",
    "deploy": "npx prisma migrate deploy",
    "dev": "npm run generate && nodemon --watch \"src/**\" --ext \"js,json\" --exec \"node src/index.js\"",
    "build": "npm run generate",
    "start": "npm run build && node build/index.js"
  },
  "prisma": {
    "schema": "prisma/schema.prisma"
  },
  "dependencies": {
    "@prisma/client": "^3.6.0"
  },
  "devDependencies": {
    "@tsconfig/node16": "^1.0.2",
    "@types/node": "^16.11.12",
    "nodemon": "^2.0.15",
    "prisma": "^3.6.0"
  }
}

I run this in Kubernetes. To make things smooth with database and migrations I run an initContainer that runs the prisma migrate deploy.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: EXAMPLE
spec:
  replicas: 1
  selector:
    matchLabels:
      app: EXAMPLE
  strategy:
    rollingUpdate:
      maxSurge: 100%
      maxUnavailable: 0
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: EXAMPLE
    spec:
      containers:
        image: DOCKER_IMAGE
        imagePullPolicy: IfNotPresent
        name: SERVICE_NAME
        ports:
        - containerPort: 8080
          name: http
          protocol: TCP
      initContainers:
      - command:
        - npm
        - run
        - deploy
        image: DOCKER_IMAGE
        imagePullPolicy: IfNotPresent
        name: database-migrate-deploy

(This is a live service I just copied and stripped away anything non essential)

I hope this could be of use to someone

Find elsewhere
🌐
Reddit
reddit.com › r/nextjs › has anyone deployed prisma recently with nextjs 13?
r/nextjs on Reddit: Has anyone deployed Prisma recently with NextJS 13?
September 10, 2023 -

I used Vercel for deployment and tried everything modifying build script to include "prisma generate" command, generating prisma in a separate folder and uploading that and postinstall script but still on every single deployment I get Prisma Client Initiation error. And all solutions work fine on my local. If anyone had experienced the same would appreciate if you have any tips on how to resolve this.

PS: I did try adding "prisma generate" in postinstall script.

Have used and deployed projects with Prisma before successfully so not sure what's different this time, also tried clearing cache multiple times and creating a new project.

🌐
Medium
medium.com › @nilesh.a.yadav.82 › fixing-the-prisma-client-did-not-initialize-yet-error-on-vercel-or-anywhere-d2d16d89e2a5
🚨 Fixing the “@prisma/client did not initialize yet” Error on Vercel (or Anywhere) | by Nilesh Yadav | Medium
July 5, 2025 - Issue Fix Prisma client not initialized Add "postinstall": "prisma generate" Works locally, fails on Vercel Add Prisma generate step Hosted PostgreSQL with SSL (Neon) Use ?sslmode=require in URL
🌐
GitHub
github.com › code100x › tiplink › issues › 21
Add Prisma Postinstall Command · Issue #21 · code100x/tiplink
August 3, 2024 - Summary: Automate Prisma Client generation by adding prisma generate to the postinstall script in package.json. This will ensure the client is always up to date after dependencies are installed. Cu...
Author   code100x
🌐
Prisma
prisma.io › home › prisma cli reference › prisma cli reference › prisma cli reference
Prisma CLI reference | Prisma Documentation
For general debugging - CI: - DEBUG: ... in Prisma ORM v7) - PRISMA_SCHEMA_ENGINE_BINARY: - PRISMA_MIGRATION_ENGINE_BINARY: For the "postinstall" npm hook - PRISMA_GENERATE_SKIP_AUTOINSTALL: (Not supported in Prisma ORM v7) - PRISMA_SKIP_POSTINSTALL_GENERATE: (Not supported ...
🌐
Lightrun
lightrun.com › answers › prisma-docs-docs-prisma-generate-post-install
Debug Daily - Real-World Developer Solutions & Troubleshooting
January 17, 2021 - Debug Daily provides real-world solutions to common developer problems. Find answers to GitHub Actions errors, React Native issues, Python bugs, and more. Sponsored by Lightrun.
🌐
GitHub
github.com › prisma › prisma › issues › 27419
Run @prisma/client postinstall on prisma generate · Issue #27419 · prisma/prisma
June 15, 2025 - Feature Summary Run the postinstall script of @prisma/client while running prisma generate if .prisma/client doesn't exist Use Cases & Problem Description pnpm uses side effects cache to cache the results of install hooks, this works for...
Author   prisma
🌐
GitHub
github.com › prisma › prisma › issues › 29308
Incremental `prisma generate` — only regenerate changed models (235s on 530 models is blocking active development) · Issue #29308 · prisma/prisma
March 6, 2026 - A typical schema change — adding a field, tweaking a relation — forces a ~4 minute wait before the app can restart. The postinstall hook in package.json ("postinstall": "prisma generate") means every npm install on CI also blocks for 235 seconds.
Author   prisma
🌐
GitHub
github.com › prisma › prisma › issues › 24678
Postinstall fails in Bun environment using `bun prisma generate`, bun x prisma generate`, etc. · Issue #24678 · prisma/prisma
June 30, 2024 - Next, I try and update Dockerfile to use npx prisma generate instead of bun prisma generate. This results in same problem. This is not our issue. When there is no nodejs present, there is no error. The moment I install nodejs in my dockerfile, or force the --bun flag to use Bun, that's when the postinstall errors come to light.
Author   prisma
🌐
GitHub
github.com › prisma › prisma › discussions › 25640
How prisma generate works without prisma.schema file? · prisma/prisma · Discussion #25640
The install command invokes prisma generate for you which reads your Prisma schema and generates a version of Prisma Client that is tailored to your models. However, if the schema.prisma file is not found, you'll see a warning message as mentioned ...
Author   prisma
🌐
GitHub
github.com › prisma › prisma › discussions › 21624
Prisma Client Generate · prisma/prisma · Discussion #21624
To resolve this issue, you can add a postinstall script in your package.json file to ensure Prisma Client is generated during the installation of node modules in the production stage.
Author   prisma
🌐
Medium
medium.com › @nolawnchairs › sharing-prisma-between-multiple-applications-5c7a7d131519
Sharing Prisma Between Multiple Applications | by Michael Wieczorek | Medium
April 1, 2024 - It simply runs Prisma’s generate command which creates the generated code from your schema. Note that we’re using npx — this is a choice so we don’t need to impose Prisma’s CLI to be installed into the project.