Bug description
When importing the Prisma client into a Next.js project, calls to functions like findOne throw an error like this:
Invalid `prisma.account.findOne()` invocation in
C:\Users\Robbie\Code\prisma-bug-test\next-app\node_modules\next\dist\next-server\server\api-utils.js:8:7
Query engine binary for current platform "windows" could not be found.
This probably happens, because you built Prisma Client on a different platform.
(Prisma Client looked in "\query-engine-windows.exe")
Files in \:
$GetCurrent
$Recycle.Bin
$WinREAgent
Config.Msi
Documents and Settings
DumpStack.log
DumpStack.log.tmp
hiberfil.sys
Intel
IntelOptaneData
pagefile.sys
PerfLogs
Program Files
Program Files (x86)
ProgramData
Python38
Recovery
swapfile.sys
System Volume Information
Users
Windows
Windows10Upgrade
To solve this problem, add the platform "windows" to the "generator" block in the "schema.prisma" file:
generator client {
provider = "prisma-client-js"
binaryTargets = ["native"]
}
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 like eval("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
- OS: Windows
- Database: PostgreSQL (although I doubt this matters since the query engine doesn't load in the first place)
- Node.js version: 12.16.3
- Prisma version:
@prisma/cli : 2.8.1
Current platform : windows
Query Engine : query-engine 439da16b2f8314c6faca7d2dad2cdcf0732e8a9c (at node_modules\@prisma\cli\query-engine-windows.exe)
Migration Engine : migration-engine-cli 439da16b2f8314c6faca7d2dad2cdcf0732e8a9c (at node_modules\@prisma\cli\migration-engine-windows.exe)
Introspection Engine : introspection-core 439da16b2f8314c6faca7d2dad2cdcf0732e8a9c (at node_modules\@prisma\cli\introspection-engine-windows.exe)
Format Binary : prisma-fmt 439da16b2f8314c6faca7d2dad2cdcf0732e8a9c (at node_modules\@prisma\cli\prisma-fmt-windows.exe)
Studio : 0.296.0
Preview Features : atomicNumberOperations
Bug description
When importing the Prisma client into a Next.js project, calls to functions like
findOnethrow 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
findOnefunction should return null.Prisma information
The schema can be found in the reproduction repo.
Environment & setup