Vercel + Prisma

Hopefully someone here can help with my issue, but I'm trying to use Prisma with solid + vercel, however I'm getting an error that "no such file or directory, open '/var/task/schema.prisma'". The issue is, that file should exist. I have other projects on vercel with solid + prisma which work fine, and I have absolutely no idea what is wrong with this one. My package.json includes a vercel-build with "prisma generate && solid-start build && cp node_modules/.pnpm/**/@prisma/engines/*query* .vercel/output/functions/render.func/ && cp prisma/schema.prisma .vercel/output/functions/render.func/" (To copy over the prisma engine/schema into the render function), however the error still appears, even though I am sure the files do get copied. Running vercel-build locally builds just fine, with the files getting moved into their proper positions (see attached image), and there are no errors when building on vercel either. I'm just at a loss at what could be happening here, as this method works perfectly fine on my other solid + prisma + vercel projects.
37 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Razboy20
Razboy202y ago
Ohhh, right, api is a separate serverless function. Thank you so much!
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Razboy20
Razboy202y ago
Feel that xD, spent hours looking at everything too
ry
ry2y ago
Is copying the prisma schema something that needs to happen on non-vercel deployments as well? Would it make sense to copy the schema into .solid/server for a more adapter agnostic approach, and have adapters copy all additional files?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
ry
ry2y ago
Yeah confirmed the schema is required on Netlify deployment as well Do you think having an adapter config would be better? Since we would not have unnecessary duplicate files in .solid
solid({
adapter: netlify({
include: ["node_modules/prisma/*engine*.node", "prisma/schema.prisma"]
})
})
solid({
adapter: netlify({
include: ["node_modules/prisma/*engine*.node", "prisma/schema.prisma"]
})
})
But it would have to flatten the directory, not sure if there is a usecase where the directory structure needs to be preserved (prisma/schema.prisma -> render.func/schema.prisma)
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
ry
ry2y ago
Opened a PR here for Vercel and Netlify https://github.com/solidjs/solid-start/pull/644
GitHub
feat: Add adapter include dir by ryoid · Pull Request #644 · solidj...
Noticed that people were running into issues (Related discord thread) using Prisma as they need to copy some files to the deployment directory. Not sure what other libraries have to do similar. An ...
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
ryansolid
ryansolid2y ago
Out of curiousity do you usually have to worry about this sort of stuff. I don't know what best pattern to follow here. This need makes sense to me. I had this fun working with serverless framework with AWS but I'm interested in things like Next automate this?
Razboy20
Razboy202y ago
Seems like next.js is able to deal with prisma as a dependency without any extra setup for vercel (or other serverless hosts) Also there isn't any specific code dealing with prisma within next.js either to make it work
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
ryansolid
ryansolid2y ago
That's like the PR we have open. I just wanted to make sure this was the best option. @.daemonic thanks for doing the legwork to look into this stuff. Really useful information.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
ry
ry2y ago
I think you would have to copy the files to both, as the api.func is simply a duplicate of the render.func with a route configuration that points api routes to it Is my understanding correct that nft alone would not be sufficient as it doesn't include schema.prisma ?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
ryansolid
ryansolid2y ago
I see, so this is a very Vercel specific thing. The splitting of api function was also very Vercel specific to deal with ISR. This atleast seems the expectation for Vercel so it seems like the right direction. Id appreciate any help. Im juggling too many high priority things right now.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
ryansolid
ryansolid2y ago
Awesome thank yo Yeah could use help with testing this if anyone has prisma demo laying around I think I will just go forward with it and we can sort it out/confirm later
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
ryansolid
ryansolid2y ago
I will publish momentarily
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
ryansolid
ryansolid2y ago
ok 0.2.18
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
ryansolid
ryansolid2y ago
This is amazing..
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
ryansolid
ryansolid2y ago
yeah thank you
aquarazorda
aquarazorda14mo ago
Hey @orjdev @.daemonic , what was the solution to this problem? Using that postbuild script doesn't help, can't figure out what to do... Sorry for tagging
Unknown User
Unknown User14mo ago
Message Not Public
Sign In & Join Server To View
aquarazorda
aquarazorda14mo ago
I'm using latest version, do I need to add something to vercel adapter or something like that?
Unknown User
Unknown User14mo ago
Message Not Public
Sign In & Join Server To View
aquarazorda
aquarazorda14mo ago
both are on 0.2.26 but I'm not using create-jd-app, just in case
aquarazorda
aquarazorda14mo ago
@orjdev I see that it's being copied here without postbuild script and it should be able to read it... Can't figure out what's the issue..
Unknown User
Unknown User14mo ago
Message Not Public
Sign In & Join Server To View
aquarazorda
aquarazorda14mo ago
Thank you for your time and response guys. I've found the solution in examples - https://github.com/solidjs/solid-start/blob/main/examples/with-prisma/vite.config.ts I had to add ssr: { external: ["@prisma/client"] } in my vite.config.ts
GitHub
solid-start/vite.config.ts at main · solidjs/solid-start
SolidStart, the Solid app framework. Contribute to solidjs/solid-start development by creating an account on GitHub.
Unknown User
Unknown User14mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server
More Posts