#Explanation of setup I have my own project (not following the full “create-next-app” guide). I have been following the Prisma Next.js guide: https://www.prisma.io/docs/guides/nextjs
Learn how to use Prisma ORM in a Next.js app and deploy it to Vercel
Solution
Solution
In the prisma.schema file, changed provider from: "prisma-client" to: "prisma-client-js"
This is my Prisma files:
schema.prisma
generator client { provider = "prisma-client-js" // ← // output = "../generated/prisma" // no output → the output will be in node_modules}datasource db { provider = "postgresql" url = env("DATABASE_PRODUCTION_URL")}
generator client { provider = "prisma-client-js" // ← // output = "../generated/prisma" // no output → the output will be in node_modules}datasource db { provider = "postgresql" url = env("DATABASE_PRODUCTION_URL")}
// lib/prisma.ts/*This will take PrismaClient from prisma folder in node_modules and the code provide a prisma client global and will only initiate once at start*/import { PrismaClient } from "@prisma/client";// func to initiate prisma clientconst prismaClientSingelton = () => { return new PrismaClient();};// Type declare const globalThis: { prismaGlobal: ReturnType<typeof prismaClientSingelton>;} & typeof global;// Use existing or initiate const prisma = globalThis.prismaGlobal ?? prismaClientSingelton();// exports it so we can use it in other filesexport default prisma;// Add prisma to hhe global instance if we aren´t in production/*⚠️ I don´t know yet how I will solve this in production or if it needs solving (prob will)*/if (process.env.NODE_ENV !== "production") globalThis.prismaGlobal = prisma;
// lib/prisma.ts/*This will take PrismaClient from prisma folder in node_modules and the code provide a prisma client global and will only initiate once at start*/import { PrismaClient } from "@prisma/client";// func to initiate prisma clientconst prismaClientSingelton = () => { return new PrismaClient();};// Type declare const globalThis: { prismaGlobal: ReturnType<typeof prismaClientSingelton>;} & typeof global;// Use existing or initiate const prisma = globalThis.prismaGlobal ?? prismaClientSingelton();// exports it so we can use it in other filesexport default prisma;// Add prisma to hhe global instance if we aren´t in production/*⚠️ I don´t know yet how I will solve this in production or if it needs solving (prob will)*/if (process.env.NODE_ENV !== "production") globalThis.prismaGlobal = prisma;