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.![](https://utfs.io/f/189f071a-c583-43d1-80a0-def734b112da-1nq2cb.png)
37 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Ohhh, right, api is a separate serverless function. Thank you so much!
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Feel that xD, spent hours looking at everything too
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•2y ago
Message Not Public
Sign In & Join Server To View
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
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•2y ago
Message Not Public
Sign In & Join Server To View
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•2y ago
Message Not Public
Sign In & Join Server To View
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?
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•2y ago
Message Not Public
Sign In & Join Server To View
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•2y ago
Message Not Public
Sign In & Join Server To View
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•2y ago
Message Not Public
Sign In & Join Server To View
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•2y ago
Message Not Public
Sign In & Join Server To View
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•2y ago
Message Not Public
Sign In & Join Server To View
I will publish momentarily
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
ok 0.2.18
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
This is amazing..
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
yeah thank you
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
![](https://answer-overflow-discord-attachments.s3.amazonaws.com/1111751272425590895/Screenshot_2023-05-27_at_12.21.41_AM.png)
Unknown User•14mo ago
Message Not Public
Sign In & Join Server To View
I'm using latest version, do I need to add something to vercel adapter or something like that?
Unknown User•14mo ago
Message Not Public
Sign In & Join Server To View
both are on 0.2.26
but I'm not using create-jd-app, just in case
@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..
![](https://answer-overflow-discord-attachments.s3.amazonaws.com/1111765685018833146/Screenshot_2023-05-27_at_1.17.31_AM.png)
![](https://answer-overflow-discord-attachments.s3.amazonaws.com/1111765685320810566/Screenshot_2023-05-27_at_1.19.13_AM.png)
Unknown User•14mo ago
Message Not Public
Sign In & Join Server To View
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.tsGitHub
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•14mo ago
Message Not Public
Sign In & Join Server To View