Generated client with custom path: ENOENT: no such file or directory, open 'D:\<projectpath>\node_modules\.prisma\client\schema.prisma
See original GitHub issueBug description
Hello, i’ve commented on #10512 and told to create a new issue.
I tried creating a client in a custom path with the @prisma/client@dev but when loading the created client it throws
ENOENT: no such file or directory, open 'D:\development\<project-workspace>\node_modules\.prisma\client\schema.prisma'
.
this is the schema used to generate the client
generator client {
provider = "prisma-client-js"
output = "./client"
previewFeatures = ["interactiveTransactions"]
binaryTargets = ["linux-musl", "darwin", "windows"]
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
I use this to generate a npm private library because I need multiple prisma clients with different schemas, so I import each of them from the corresponding library:
const client1 = await import('@myorg/prisma1').PrismaClient
const client2 = await import('@myorg/prisma2').PrismaClient
const prismaClient1 = new client({ datasources: { db: { url: this.prepareUrl(factoryOptions) } } })
But upon instantiating any one of them it produces that ENOENT error.
The libraries I mentioned have the following folder structure when installed in the consuming project:
inside node_modules/@myorg:
How to reproduce
- generate a prisma client with a custom path on a separate directory.
- Install the directory as a dependency on another project
- Load the generated client from the custom directory into the project
- Instantiate the client
Expected behavior
It would be expected the generated client to be capable of loading the runtime and prisma.schema from within it’s own directory when an output path is specified on the .schema
Prisma information
generator client {
provider = "prisma-client-js"
output = "./client"
previewFeatures = ["interactiveTransactions"]
binaryTargets = ["linux-musl", "darwin", "windows"]
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
Environment & setup
- OS: windows
- Database: mysql
- Node.js version: 16
Prisma Version
prisma : 3.13.0-dev.3
@prisma/client : 3.13.0-dev.3
Current platform : windows
Query Engine (Node-API) : libquery-engine ba8e3c2c2615e6af9303b3930e7de9377999a0e7 (at node_modules\@prisma\engines\query_engine-windows.dll.node)
Migration Engine : migration-engine-cli ba8e3c2c2615e6af9303b3930e7de9377999a0e7 (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine : introspection-core ba8e3c2c2615e6af9303b3930e7de9377999a0e7 (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary : prisma-fmt ba8e3c2c2615e6af9303b3930e7de9377999a0e7 (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash : ba8e3c2c2615e6af9303b3930e7de9377999a0e7
Studio : 0.459.0
ALSO TRIED WITH
Environment variables loaded from .env
prisma : 3.12.0
@prisma/client : 3.12.0
Current platform : windows
Query Engine (Node-API) : libquery-engine 22b822189f46ef0dc5c5b503368d1bee01213980 (at node_modules\@prisma\engines\query_engine-windows.dll.node)
Migration Engine : migration-engine-cli ba8e3c2c2615e6af9303b3930e7de9377999a0e7 (at node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine : introspection-core ba8e3c2c2615e6af9303b3930e7de9377999a0e7 (at node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary : prisma-fmt ba8e3c2c2615e6af9303b3930e7de9377999a0e7 (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash : 22b822189f46ef0dc5c5b503368d1bee01213980
Studio : 0.459.0
Issue Analytics
- State:
- Created a year ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
Getting something similar on a monorepo multi zone nextjs project
Trying to use prisma in an internal package but each app is giving a prisma error - unable to find schema.prisma same as here
I’m using custom generated client location, and have tried without a files [] and with, haven’t found any success
if I manually copy paste the schema.prisma into the next build, it seems to at least cause different errors, but all the same feels like there’s still something I’m missing here?
Tried based on @TheVoid-0’s comments to adjust a files[] to include the .node files etc but wasn’t able to get any working config off of that
Yes @janpio you are correct, the only files missing on the published library were the query engines .node ones, once I’ve included them all started working without any problems so far. It looks like if they are missing, prisma fall back to look for everything on the default location
node_modules/.prisma
Wich will not exist in this scenario. Not sure what prisma should do, but perhaps showing an error message that the query engines are missing would give a better hint that something in the building and/or packaging went wrong.