Next.js Discord

Discord Forum

Prisma, NextJs and Cloudflare FS error no matter what I do

Answered
bear posted this in #help-forum
Open in Discord
I am trying to use Prisma ORM with D1 in NextJs on Cloudflare Workers. This works when running npm run dev. However, as soon as I attempt to use npm run preview or npm run deploy my website breaks and returns the following error when I try to use any server functions. I believe this has something to do with prisma since it is trying to access the file system, but I have driverAdapters enabled so prisma should work on the edge.
my repo is: https://github.com/BearTyree/Flash-Royale
the error is:
Error: [unenv] fs.readdir is not implemented yet!
    at createNotImplementedError (file:///H:/Git/flash-royale/node_modules/unenv/dist/runtime/_internal/utils.mjs:25:9)
    at Object.fn [as readdir] (file:///H:/Git/flash-royale/node_modules/unenv/dist/runtime/_internal/utils.mjs:30:9)
    at nc (file:///H:/Git/flash-royale/.open-next/server-functions/default/handler.mjs:337:2096)
    at Ko (file:///H:/Git/flash-royale/.open-next/server-functions/default/handler.mjs:337:2026)
    at tc (file:///H:/Git/flash-royale/.open-next/server-functions/default/handler.mjs:337:1491)
    at async Zo (file:///H:/Git/flash-royale/.open-next/server-functions/default/handler.mjs:336:7116)
    at async es (file:///H:/Git/flash-royale/.open-next/server-functions/default/handler.mjs:337:2477)
    at async ir (file:///H:/Git/flash-royale/.open-next/server-functions/default/handler.mjs:337:2260)
    at async Gr.getCurrentBinaryTarget (file:///H:/Git/flash-royale/.open-next/server-functions/default/handler.mjs:443:13360)
    at async Gr.instantiateLibrary (file:///H:/Git/flash-royale/.open-next/server-functions/default/handler.mjs:443:13148) {
  clientVersion: '6.9.0'
}
[wrangler:info] POST /signup 200 OK (21ms)
Answered by bear
For anyone finding this in the future:
The solution is to either not use windows, or not use prisma.
https://github.com/sommeeeer was able to get my repo working on linux after wiping the folders rm -rf .next .open-next .wrangler node_modules and trying again.
I was able to get drizzle working on windows in dev and preview so I recommend using that instead of prisma if you are on windows.
View full answer

2 Replies

For anyone finding this in the future:
The solution is to either not use windows, or not use prisma.
https://github.com/sommeeeer was able to get my repo working on linux after wiping the folders rm -rf .next .open-next .wrangler node_modules and trying again.
I was able to get drizzle working on windows in dev and preview so I recommend using that instead of prisma if you are on windows.
Answer