next.js ENOENT trying to open schema.prisma
See original GitHub issueBug description
In a monorepo, when exporting PrismaClient
from one package and consuming it in a next.js api route, I get
error - Error: ENOENT: no such file or directory, open 'C:\Users\sbere\Desktop\Projects\prisma-pnpm-workspace-test\apps\frontend\.next\server\pages\api\schema.prisma'
How to reproduce
pnpm install
cd packages/prisma
pnpx prisma generate
cd ../../apps/frontend
pnpm run dev
- send a GET request to
localhost:3000/api/hello
Expected behavior
The api runs as expected
Prisma information
prisma:tryLoadEnv Environment variables not found at null +0ms
prisma:tryLoadEnv Environment variables not found at undefined +0ms
prisma:tryLoadEnv No Environment variables loaded +1ms
prisma:tryLoadEnv Environment variables not found at null +1ms
prisma:tryLoadEnv Environment variables not found at undefined +0ms
prisma:tryLoadEnv No Environment variables loaded +0ms
prisma:client dirname C:\Users\sbere\Desktop\Projects\prisma-pnpm-workspace-test\apps\frontend\.next\server\pages\api +0ms
prisma:client relativePath ..\..\..\..\..\..\packages\prisma +0ms
prisma:client cwd C:\Users\sbere\Desktop\Projects\prisma-pnpm-workspace-test\packages\prisma +0ms
prisma:client clientVersion: 3.12.0 +2ms
prisma:client clientEngineType: library +0ms
Environment & setup
- OS: Windows 11
- Database: PostgreSQL
- Node.js version: v16.14.2
Prisma Version
prisma : 3.12.0
@prisma/client : 3.12.0
Current platform : windows
Query Engine (Node-API) : libquery-engine 22b822189f46ef0dc5c5b503368d1bee01213980 (at ..\..\node_modules\.pnpm\@prisma+engines@3.12.0-37.22b822189f46ef0dc5c5b503368d1bee01213980\node_modules\@prisma\engines\query_engine-windows.dll.node)
Migration Engine : migration-engine-cli 22b822189f46ef0dc5c5b503368d1bee01213980 (at ..\..\node_modules\.pnpm\@prisma+engines@3.12.0-37.22b822189f46ef0dc5c5b503368d1bee01213980\node_modules\@prisma\engines\migration-engine-windows.exe)
Introspection Engine : introspection-core 22b822189f46ef0dc5c5b503368d1bee01213980 (at ..\..\node_modules\.pnpm\@prisma+engines@3.12.0-37.22b822189f46ef0dc5c5b503368d1bee01213980\node_modules\@prisma\engines\introspection-engine-windows.exe)
Format Binary : prisma-fmt 22b822189f46ef0dc5c5b503368d1bee01213980 (at ..\..\node_modules\.pnpm\@prisma+engines@3.12.0-37.22b822189f46ef0dc5c5b503368d1bee01213980\node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash : 22b822189f46ef0dc5c5b503368d1bee01213980
Studio : 0.459.0
Issue Analytics
- State:
- Created a year ago
- Reactions:11
- Comments:21
Top Results From Across the Web
Best practice for instantiating PrismaClient with Next.js
Solution. The solution in this case is to instantiate a single instance PrismaClient and save it on the global object. Then we keep...
Read more >Taxonomy - Vercel
~Prisma: Error: ENOENT: no such file or directory, open '/var/task/.next/server/chunks/schema.prisma'~; ~Next.js 13: Client side navigation does not update head ...
Read more >ENOENT: no such file or directory, open '/var/task/src/schema ...
I've been trying to get deploy an app running express, ts & prisma, using serverless. I keep running into the following error:
Read more >An open source application built using the new router, server ...
GitHub authentication (use email); Prisma: Error: ENOENT: no such file or directory, open '/var/task/.next/server/chunks/schema.prisma' ...
Read more >shadcn on Twitter: "Found a temp fix for the @prisma on ...
Next.js 13 - ENOENT: no such file or directory, open /var/task/.next/server/chunks/schema.prisma ·... Bug description When deploying a Next.js 13 (with app ...
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 FreeTop 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
Top GitHub Comments
I fixed this adding to
.npmrc
the following, this forces the prisma package to remain on top of the monorepo i thinkIf you’re using nextjs v13, try adding prisma to the
serverComponentsExternalPackages
in your config:https://beta.nextjs.org/docs/api-reference/next.config.js#servercomponentsexternalpackages