<p>I am using prisma, postgres, docker, kubernets.</p>
<p><strong>npx prisma migrate dev</strong> working.</p>
<p>and <strong>npx prisma generate</strong> produce below output:</p>
<pre><code>✔ Generated Prisma Client (2.23.0) to ./node_modules/@prisma/client in 68ms
You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client

import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()
</code></pre>
<p>but when I tried to use in my route file produce the error:</p>
<p>new-route.ts</p>
<pre><code>import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient();
</code></pre>
<p>my docker file:</p>
<pre><code>FROM node:alpine

WORKDIR /app
COPY package.json .
RUN npm install --only=prod
COPY . .

CMD [&quot;npm&quot;, &quot;start&quot;]
</code></pre>

<p>I know that this has been marked as solved, but I just wanted to share my setup for anyone interested.</p>
<p>Dockerfile</p>
<pre><code># 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 [&quot;node&quot;, &quot;src/index.js&quot;]

</code></pre>
<p>package.json</p>
<pre><code>{
  &quot;name&quot;: &quot;example&quot;,
  &quot;description&quot;: &quot;&quot;,
  &quot;version&quot;: &quot;0.1.0&quot;,
  &quot;scripts&quot;: {
    &quot;generate&quot;: &quot;npx prisma generate&quot;,
    &quot;deploy&quot;: &quot;npx prisma migrate deploy&quot;,
    &quot;dev&quot;: &quot;npm run generate &amp;&amp; nodemon --watch \&quot;src/**\&quot; --ext \&quot;js,json\&quot; --exec \&quot;node src/index.js\&quot;&quot;,
    &quot;build&quot;: &quot;npm run generate&quot;,
    &quot;start&quot;: &quot;npm run build &amp;&amp; node build/index.js&quot;
  },
  &quot;prisma&quot;: {
    &quot;schema&quot;: &quot;prisma/schema.prisma&quot;
  },
  &quot;dependencies&quot;: {
    &quot;@prisma/client&quot;: &quot;^3.6.0&quot;
  },
  &quot;devDependencies&quot;: {
    &quot;@tsconfig/node16&quot;: &quot;^1.0.2&quot;,
    &quot;@types/node&quot;: &quot;^16.11.12&quot;,
    &quot;nodemon&quot;: &quot;^2.0.15&quot;,
    &quot;prisma&quot;: &quot;^3.6.0&quot;
  }
}
</code></pre>
<p>I run this in Kubernetes. To make things smooth with database and migrations I run an initContainer that runs the <code>prisma migrate deploy</code>.</p>
<pre><code>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
</code></pre>
<p>(This is a live service I just copied and stripped away anything non essential)</p>
<p>I hope this could be of use to someone</p>
