Next.js 13 - ENOENT: no such file or directory, open /var/task/.next/server/chunks/schema.prisma
See original GitHub issueBug description
When deploying a Next.js 13 (with app dir) on Vercel, I’m seeing the following error:
Error: ENOENT: no such file or directory, open '/var/task/.next/server/chunks/schema.prisma'
at Object.openSync (node:fs:585:3)
at Object.readFileSync (node:fs:453:35)
at new LibraryEngine (/var/task/.next/server/chunks/538.js:28292:45)
at PrismaClient.getEngine (/var/task/.next/server/chunks/538.js:32706:24)
at new PrismaClient (/var/task/.next/server/chunks/538.js:32678:37)
at Object.4963 (/var/task/.next/server/app/page.js:374:14)
at __webpack_require__ (/var/task/.next/server/webpack-runtime.js:25:42)
at page (/var/task/.next/server/app/page.js:237:87)
at createComponentTree (/var/task/node_modules/next/dist/server/app-render.js:578:80)
at /var/task/node_modules/next/dist/server/app-render.js:663:62 {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: '/var/task/.next/server/chunks/schema.prisma',
clientVersion: '4.5.0',
page: '/'
}
RequestId: 9ce84669-6d69-44b5-a6fc-f6e572a6a845 Error: Runtime exited with error: exit status 1
Runtime.ExitError
I’ve tried a few apps to try and reproduce this and this only happens when you make the page dynamic.
A few ways I’ve been able to reproduce this:
- Using the
export const revalidate = 0
segment config on a page - Calling
headers()
from “next/headers” inside the page.
✅ This works:
import { db } from "@/lib/db"
export default async function Page() {
const messages = await db.message.findMany()
return ...
}
❌ This does not work:
import { db } from "@/lib/db"
export const revalidate = 0 // 👈 Adding this results in the error above.
export default async function Page() {
const messages = await db.message.findMany()
return ...
}
❌ This does not work:
import { headers } from "next/headers"
import { db } from "@/lib/db"
export default async function Page() {
headers() // 👈 Adding this results in the error above.
const messages = await db.message.findMany()
return ...
}
How to reproduce
I have a sample app here: https://github.com/shadcn/next-prisma-app
- Create a new Next.js 13 app with a prisma model.
- Create a new file at
app/page.tsx
and try calling prisma there. - Add
export const revalidate = 0
- Deploy to Vercel and try accessing the page at
/
- You should the error above.
- Remove the export and try again.
- Error should be gone.
Expected behavior
Expected prisma to work with the segment config.
Prisma information
generator client {
provider = "prisma-client-js"
previewFeatures = ["referentialIntegrity"]
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
referentialIntegrity = "prisma"
}
model Message {
id Int @id @default(autoincrement())
content String?
}
Environment & setup
- OS: Vercel (works fine locally on MacOS)
- Database: MySQL
- Node.js version: 16
Prisma Version
prisma : 4.5.0
@prisma/client : 4.5.0
Current platform : darwin
Query Engine (Node-API) : libquery-engine 0362da9eebca54d94c8ef5edd3b2e90af99ba452 (at node_modules/@prisma/engines/libquery_engine-darwin.dylib.node)
Migration Engine : migration-engine-cli 0362da9eebca54d94c8ef5edd3b2e90af99ba452 (at node_modules/@prisma/engines/migration-engine-darwin)
Introspection Engine : introspection-core 0362da9eebca54d94c8ef5edd3b2e90af99ba452 (at node_modules/@prisma/engines/introspection-engine-darwin)
Format Binary : prisma-fmt 0362da9eebca54d94c8ef5edd3b2e90af99ba452 (at node_modules/@prisma/engines/prisma-fmt-darwin)
Format Wasm : @prisma/prisma-fmt-wasm 4.5.0-43.0362da9eebca54d94c8ef5edd3b2e90af99ba452
Default Engines Hash : 0362da9eebca54d94c8ef5edd3b2e90af99ba452
Studio : 0.476.0
Preview Features : referentialIntegrity
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:17 (3 by maintainers)
Top Results From Across the Web
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 >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 >How to fix NextJS enoent? - Stack Overflow
I'd the same problem, in my case i just try it: PS. this fix is not permanent, this is just a stopgap solution....
Read more >An open source application built using the new router, server ...
Prisma: Error: ENOENT: no such file or directory, open '/var/task/.next/server/chunks/schema.prisma' · Next.js 13: Client side navigation does ...
Read more >ENOENT: no such file or directory when deployed to Vercel
Nothing too major, but one of the things I decided to do was to bump my current Nextjs version from the version I...
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
^ Prisma is now added to the default list, I’ve updated the docs there to reflect that.
I’ve temporarily generated the prisma-client to src dir, bypassing this problem
db.ts