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.55 Replies
GitHub
split vercel api routes function (#613) · solidjs/solid-start@0efce88
* fix: split vercel api routes func
* fix: create route for every api route
now it should be
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?Im pretty sure all adapters have to do this
But personally i use vercel so ik that it is a requirement
Ig you could try and lmk if it works or we could figure something out
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
)Adapter config would be much better yes but we have to play a few tricks to get it to work with all adapters
Will take a look
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 ...
Not sure how netlify should be working but the vercel one looks good to me
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.
^, looking at the information provided isn’t
include
an ideal way to solve this problem? If astro does that, then 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
?Prisma engines should be copied into both in order not to change anything within prisma code / configuration itself
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Yes it does copy it
Otherwise we would face the exact same problem when using nextjs
But we don’t
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
Sure will try to, but looks good to me. Thanks
I will publish momentarily
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Awesome looks like you are not using the postbuild script so i will update create-jd-app and remove this script when its published
Out of context but it is slow because you forgot to update the getBaseUrl script within utils/trpc.ts
After it checks wether the window is defined or not, add this line:
ok 0.2.18
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
GitHub
Release v0.1.11 · OrJDev/create-jd-app
Patch Changes
387d038 Thanks @OrJDev! - Bump to 0.2.18 in order to delete the prisma postbuild script
a9a96a3 Thanks @OrJDev! - Better queryClient options for trpc + ssr
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
This is amazing..
ye
https://github.com/solidjs/solid-start/pull/644 this can be closed ig
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 require similar.
An ada...
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
ah yes true, should seek for another solution for netlify aswell
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
cool let us know
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
You can upgrade solid start to its latest versions, it has been fixed in the nft api usage
I'm using latest version, do I need to add something to vercel adapter or something like that?
No, just make sure the vercel adapter is also on its latest
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..
Yes im not sure what is it exactly as create jd app creates a ready to deploy app, can you make an issue on the repo and share a repro
Unknown User•2y 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.
That’s something that create jd app already does
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View