New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generated client with custom path containing string client
: ENOENT: no such file or directory, open 'D:\<projectpath>\node_modules\.prisma\client\schema.prisma
#12719
Comments
Can you try to use the generated Prisma Clients directly? |
Thanks for the answer. What do you mean by directly? generating and using the generated client directly on the application that's supposed to use prisma? I could do that, but that's exactly the burden we are trying to avoid. If every application needs to generate the client, this means we need to keep several .schemas in sync at each change, and also update each Dockerfile or build scripts whatsoever to generate the clients on each build for every application as well. If that's not what you mean, please let me know. About the private library, that screenshot I showed about @myorg/prisma-geral is the whole library, on the library itself I have the dependencies on the @prisma/client and prisma cli to generate the client on a custom path based on the schema, this outputs that lib/ that can be seen on the screenshot. Then the library can be added normally with This is the package.json of the library: {
"name": "@myorg/prisma-geral",
"version": "1.0.0",
"description": "add description",
"types": "lib/client/index.d.ts",
"main": "lib/client/index.js",
"files": [
"lib/*.js",
"lib/*.ts",
"lib/**/*.js",
"lib/**/*.ts",
"lib/*.prisma"
],
"scripts": {
"build": "npx prisma db pull --schema=lib/schema.prisma && rimraf lib/client && prisma generate --schema=lib/schema.prisma",
"pre:publish": "rimraf ./lib/client && npx prisma generate --schema=lib/schema.prisma && yarn publish",
"test": "jest"
},
"dependencies": {
"@prisma/client": "^3.12.0"
},
"devDependencies": {
"@types/node": "^17.0.22",
"prettier": "^2.3.2",
"prisma": "^3.12.0",
"rimraf": "^3.0.2"
},
"license": "ISC"
} I was trying to reproduce the issue on a smaller repository and made it work by accident while installing the libraries locally i.e |
Sorry, should have elaborated. I meant: |
I said before that I've made it work by accident but I guess I was dreaming, could not make it work again anyway, here is a reproducible example https://github.com/TheVoid-0/issue-prisma-enoent-schema.prisma if someone could aid me with some insights. I do not know what exactly prisma would need to work in a package, I've assumed that as long as it had it's client it would work, maybe I'm missing something simple? @janpio thanks for elaborating, yes i've tried that before inside the own prisma package I was creating to see if the custom path was working correctly, and was successfull // inside the package prisma-geral/lib
const prisma = new (await import('./client')).PrismaClient()
console.log('created') // No error is thrown The issue seems to appear when the client is called from out of the scope of the package: const prisma = new (await import('@myorg/prisma-geral')).PrismaClient() // this points to: ./node_modules/@myorg/prisma-geral/lib/client
console.log('created') // error is thrown before reaching here Thanks again for taking your time |
Well, turns out that I was only being stupid, sorry for wasting your time, prisma works as intended so far. In my package I was only publishing the "js" part of the generated client, the policy I've set to package.json.files was letting the query engines out, so when importing the package it would obviously not work. So if others try to do the same, don't be like me and assure you are publishing everything prisma needs, wich is, everything that is inside de output folder. Unfortunately the error message stranded me pretty far and this was the last thing I checked. Completly my fault anyway. Thanks for the help and sorry for the useless issue! |
That is an interesting error case that we were also definitely not aware of yet. What is confusing me, if I understood correctly you did include the |
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 |
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 |
ENOENT: no such file or directory, open 'D:\<projectpath>\node_modules\.prisma\client\schema.prisma
any updates here? I'm having the same issue in monorepo nextjs project with turbo. |
If you have a monorepo, then you have the same or similar error message but a different problem @amirmamaghani. Please open a new issue and optimally include a reproduction project for your situation - then we can take a look. Thanks! |
ENOENT: no such file or directory, open 'D:\<projectpath>\node_modules\.prisma\client\schema.prisma
client
: ENOENT: no such file or directory, open 'D:\<projectpath>\node_modules\.prisma\client\schema.prisma
Bug 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
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:
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
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
Environment & setup
Prisma Version
ALSO TRIED WITH
The text was updated successfully, but these errors were encountered: