`new PrismaClient()` can not find `schema.prisma` file when use with pnpm workspace
See original GitHub issueBug description
Here is a simple reproduction with pnpm.
- packages
- server
- index.mjs # get PrismaClient from prisma-client
- package.json
- prisma-client
- dist # prisma generator output
- prisma
- schema.prisma
- package.json
- pnpm-workspace.yaml
- package.json
When call new PrismaClient
in packages/server/index.mjs
, got an error:
Error: ENOENT: no such file or directory, open '~/prisma-path-issue/packages/server/node_modules/schema.prisma'
at Object.openSync (node:fs:585:3)
at Object.readFileSync (node:fs:453:35)
at new LibraryEngine (~/prisma-path-issue/packages/prisma-client/dist/runtime/index.js:36041:40)
at PrismaClient.getEngine (~/prisma-path-issue/packages/prisma-client/dist/runtime/index.js:39247:16)
at new PrismaClient (~/prisma-path-issue/packages/prisma-client/dist/runtime/index.js:39218:29)
at getPrisma (file://~/prisma-path-issue/packages/server/index.mjs:4:18)
at file://~/prisma-path-issue/packages/server/index.mjs:9:1
at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:281:24) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '~/prisma-path-issue/packages/server/node_modules/schema.prisma',
clientVersion: '3.5.0'
}
How to reproduce
(Require global pnpm installed)
- Clone git
https://github.com/mervinjin/prisma-issue
- Run
pnpm install
- Run
pnpm start
- See error
Expected behavior
No Error
Prisma information
Schema file:
datasource db {
provider = "sqlite"
url = "file:./dev.db"
}
generator client {
provider = "prisma-client-js"
output = "../dist"
}
model User {
id Int @id @default(autoincrement())
}
Usage:
import { PrismaClient } from 'prisma-client'
async function getPrisma(){
const prisma = new PrismaClient()
await prisma.$connect()
return prisma
}
getPrisma().then(console.log)
Environment & setup
- OS: Mac OS
- Database: SQLite
- Node.js version: 17.0.1
Prisma Version
prisma : 3.5.0
@prisma/client : 3.5.0
Current platform : darwin
Query Engine (Node-API) : libquery-engine 78a5df6def6943431f4c022e1428dbc3e833cf8e (at ../../node_modules/.pnpm/@prisma+engines@3.5.0-38.78a5df6def6943431f4c022e1428dbc3e833cf8e/node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine : migration-engine-cli 78a5df6def6943431f4c022e1428dbc3e833cf8e (at ../../node_modules/.pnpm/@prisma+engines@3.5.0-38.78a5df6def6943431f4c022e1428dbc3e833cf8e/node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core 78a5df6def6943431f4c022e1428dbc3e833cf8e (at ../../node_modules/.pnpm/@prisma+engines@3.5.0-38.78a5df6def6943431f4c022e1428dbc3e833cf8e/node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary : prisma-fmt 78a5df6def6943431f4c022e1428dbc3e833cf8e (at ../../node_modules/.pnpm/@prisma+engines@3.5.0-38.78a5df6def6943431f4c022e1428dbc3e833cf8e/node_modules/@prisma/engines/prisma-fmt-darwin)
Default Engines Hash : 78a5df6def6943431f4c022e1428dbc3e833cf8e
Studio : 0.439.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Using Prisma with Yarn v3 - Stack Overflow
I've just made a new branch in git and am trying to move my project to use PnP. However, when I run yarn...
Read more >Prisma - Browse /3.12.0 at SourceForge.net
For more information, see the SourceForge Open Source Mirror Directory. ... new PrismaClient() can not find schema.prisma file when use with pnpm workspace...
Read more >Using Prisma with Turborepo
Run npx prisma init . This should create several files inside packages/database : prisma/schema.prisma .gitignore ...
Read more >With the newest version of pnpm 7 2 1 I get an error with th | Prisma
... with the prisma client package name ERR PNPM BAD PACKAGE JSON pnpm workspace ... This is no problem, the folder structure is...
Read more >Deploying sveltekit app on vercel, problems (fetching ... - Reddit
This is my endpoint code: // /users/index.js import { PrismaClient } from '@prisma/client'; const prisma = new PrismaClient(); export const get = ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Shouldn’t the goal be that this just works as intended, without any further need to specify anything?
Hey @plimeor @andyjy I can confirm that this issue has been fixed. I just ran the repro with
@prisma/client@dev
which works now 😃. If you want, you can also try it, and please let us know if you find anything unexpected. Thanks!