Prisma Client path location issue #29318
Replies: 14 comments 1 reply
|
I ran the following Prisma updates and the error disappeared: Update available 6.19.2 -> 7.4.2 This is a major update - please follow the Guide Run the following to update npm i --save-dev prisma@latest However, the following error message appears in my console when I run the 'npx tsx script.ts' command in my terminal. 1) lib/prisma.ts import { Pool } from 'pg' // 1. Create a connection pool using the 'pg' driver // 2. Initialize the Prisma adapter // 3. Pass the adapter to the PrismaClient /* import "dotenv/config"; const pool = new Pool({ connectionString: process.env.DATABASE_URL }) export { prisma }; */ 2) prisma/schema.prisma generator client { datasource db { // followed my the models 3) prisma.config.ts // This file was generated by Prisma and assumes you have installed the following: export default defineConfig({
import { prisma } from "./lib/prisma"; async function main() { // Fetch all employers main() Thanks. K. |
|
In Prisma 7 the Make sure your config points to the schema correctly: // prisma.config.ts
import path from "node:path";
import { defineConfig } from "prisma/config";
export default defineConfig({
earlyAccess: true,
schema: path.join(__dirname, "prisma", "schema.prisma"),
});After running import { PrismaClient } from "./generated/prisma/client";If you want to skip the hassle, drop the custom |
|
Hi Felipeness, Thanks for your help. I followed your suggestions. // prisma.config.ts
import path from "node:path";
import { defineConfig } from "prisma/config";
export default defineConfig({
earlyAccess: true,
schema: path.join(__dirname, "prisma", "schema.prisma"),
});and added in my prisma.ts file: // prisma.ts
import { Pool } from 'pg'
import { PrismaPg } from '@prisma/adapter-pg'
import { PrismaClient } from "./generated/prisma/client"; // your suggestion
const pool = new Pool({ connectionString: process.env.DATABASE_URL })
const adapter = new PrismaPg(pool)
const prisma = new PrismaClient({ adapter })When I run I am new to all of this. Can I now go ahead and properly query my tables in your opinion? Thanks. K. |
|
Hey! I think the issue might be simpler than it looks — looking at the error, it seems like the npm install pg
npm install -D @types/pgAlso, a couple of small things you might want to clean up:
generator client {
provider = "prisma-client"
output = "../generated/prisma"
}
After installing |
|
One more thing — after installing This happens because Prisma 7's If that happens, the way I remember fixing it is by adding generator client {
provider = "prisma-client"
output = "../generated/prisma"
importFileExtension = ""
}Then run |
|
Hey K.! Good news — the error changed, which means we're making progress. Now it's But I noticed something important in your generate output: You're still on Prisma 6.19.2, not 7. That explains a lot of the confusion — you have v7-style configs running on a v6 engine. Instead of installing packages one at a time, let's get everything in sync at once: npm install prisma@latest @prisma/client@latest @prisma/adapter-pg pg
npm install -D @types/pgThis will upgrade you to Prisma 7 for real and install all the missing dependencies. After that, update your schema.prisma: generator client {
provider = "prisma-client"
output = "../generated/prisma"
importFileExtension = "ts"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}Quick correction from my previous suggestion: Your prisma.config.ts stays simple: import "dotenv/config";
import path from "node:path";
import { defineConfig } from "prisma/config";
export default defineConfig({
schema: path.join(__dirname, "prisma", "schema.prisma"),
datasource: {
url: process.env.DATABASE_URL,
},
});Note the And your lib/prisma.ts — in Prisma 7, import "dotenv/config";
import { PrismaPg } from "@prisma/adapter-pg";
import { PrismaClient } from "../generated/prisma";
const adapter = new PrismaPg({ connectionString: process.env.DATABASE_URL });
const prisma = new PrismaClient({ adapter });
export { prisma };Then run: npx prisma generate
npx tsx script.tsOne more thing — you're on Node.js v25.2.1, which is a very recent unstable release. If you keep running into weird issues after fixing the above, consider switching to Node 22 LTS — it's much more battle-tested with Prisma and the ecosystem in general. Let me know how it goes! |
|
Hi Felipeness!
I tried the following commands: npm install prisma@latest @prisma/client@latest @prisma/adapter-pg pg
npm install -D @types/pg
Can you show me the light? Thanks a lot. Kâmi |
|
Hi Felipeness! I think we are getting closer.
The only issue (which we have seen before) is when I run I tried to google what's in the red rectangle but could not get further. Any ideas? Thanks. Kâmi |
|
The The generated client uses generator client {
provider = "prisma-client"
output = "../generated/prisma"
importFileExtension = "ts"
}Then regenerate and run: npx prisma generate
npx tsx script.tsAlso make sure your import path in import { PrismaClient } from '../generated/prisma/client'If generator client {
provider = "prisma-client"
}import { PrismaClient } from '@prisma/client'This avoids all path resolution issues and is the easiest setup for getting started. |
|
The issue with your Prisma client path seems to be related to how the output is configured in your schema.prisma file. When using
Can you share your full project structure? That would help identify the exact path issue. |
|
I assume the answers mentioned above has resolved the issue you were facing. Please feel free to open a new discussion in case you are still observing any issues. Thanks! |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Question
Hi,
(newbie question):
I created a Supabase database (with two tables) and managed to use my Supabase credentials to set up Prisma 7.
The models in schema.prisma seem to match Supabase tables and I no longer encounter errors when I run the command 'npx prisma generate'.
However, it looks like some configuration path is not properly defined.
I was hoping someone could help me and maybe point me in the right direction.
The link to my schema.prisma file below and the attached screenshots below should give you a better picture.
(I am not using Prisma Accelerate) my schema.prisma file: https://limewire.com/d/CTHx4#RG2ECUWH3Q
Screenshot 1: https://ibb.co/FkYcTVdY
Screenshot 2: https://ibb.co/zh5bzBHx
Screenshot 1:
Screenshot 2:
Thanks very much for your time and patience.
K.
All reactions