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
Prisma client looks in root directory (C:\) for engine binary when used with Next.js #5082
Comments
Hey @RobbieGM Sorry for the late reply here, I am unable to reproduce this issue withe 2.13.1 release. Can you please try this again with the latest version? |
Thanks for your reply, The version you used to attempt to reproduce the bug looks newer than the one I had the bug with. I'll upgrade and let you know if the problem persists. |
Hey @RobbieGM, did you have time to check this again? Would be great so we know if we can close this issue or need to investigate further. |
I'm a bit busy at the moment but I'll get to it when I can. |
@janpio I've updated my repository to the latest version (2.14.0) and the error message is different now. It shows:
If you clone the repository again and repeat the instructions inside you should be able to reproduce this new error. |
@RobbieGM Please have the client generated inside the next project otherwise next will try to bundle built in node core libs resulting the the string_encoder error which is core node js lib. |
What if I want to use the same prisma schema and generated code for two other folders or subprojects? My idea was to put it in a third folder and import it, but this caused the problem I was getting. Since only one of them is a finicky Next.js project and the other is plain JS/TS, I could put it in the Next project and import it from the other one. Is this my best option at this point? |
@RobbieGM Solution there is to use a monorepo tool like lerna or nx. |
Bug description
When importing the Prisma client into a Next.js project, calls to functions like
findOne
throw an error like this:Adding
binaryTargets = ["native"]
does not help, since the problem is that Prisma looks in the root directory for its binaries. I can only guess that the reason that this bug only shows up in Next.js and not regular Node environments is that Next.js uses Webpack and Babel, which may transform the code and break hacks likeeval("require('path')")
found in the Prisma node engine code.How to reproduce
Clone this repo and follow the instructions in the README.
Expected behavior
There should be no error, and the
findOne
function should return null.Prisma information
The schema can be found in the reproduction repo.
Environment & setup
The text was updated successfully, but these errors were encountered: