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
OrJDev
OrJDev2y ago
now it should be
OrJDev
OrJDev2y ago
"postbuild": "cp node_modules/prisma/*engine*.node .vercel/output/functions/render.func/ && cp prisma/schema.prisma .vercel/output/functions/render.func/ && cp node_modules/prisma/*engine*.node .vercel/output/functions/api.func/ && cp prisma/schema.prisma .vercel/output/functions/api.func/"
"postbuild": "cp node_modules/prisma/*engine*.node .vercel/output/functions/render.func/ && cp prisma/schema.prisma .vercel/output/functions/render.func/ && cp node_modules/prisma/*engine*.node .vercel/output/functions/api.func/ && cp prisma/schema.prisma .vercel/output/functions/api.func/"
or https://github.com/OrJDev/create-jd-app/commit/8421d66014b46826a9df3241c71fbab25c08c593#diff-4000ee9b1122b86c4bcd305fa87775831f50701a80996730831ec9e0639a4fd2R48
Razboy20
Razboy20OP2y 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
Razboy20OP2y 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?
OrJDev
OrJDev2y ago
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
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)
OrJDev
OrJDev2y ago
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
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 ...
OrJDev
OrJDev2y ago
Not sure how netlify should be working but the vercel one looks good to me
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
Razboy20OP2y 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.
OrJDev
OrJDev2y ago
^, looking at the information provided isn’t include an ideal way to solve this problem? If astro does that, then solid
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 ?
OrJDev
OrJDev2y ago
Prisma engines should be copied into both in order not to change anything within prisma code / configuration itself
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
OrJDev
OrJDev2y ago
Yes it does copy it Otherwise we would face the exact same problem when using nextjs But we don’t
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
OrJDev
OrJDev2y ago
Sure will try to, but looks good to me. Thanks solid
ryansolid
ryansolid2y ago
I will publish momentarily
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
OrJDev
OrJDev2y ago
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:
if(process.env.NODE_ENV === "production") return "https://jd-app-phi.vercel.app";
if(process.env.NODE_ENV === "production") return "https://jd-app-phi.vercel.app";
ryansolid
ryansolid2y ago
ok 0.2.18
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
OrJDev
OrJDev2y ago
solid
OrJDev
OrJDev2y ago
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
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
ryansolid
ryansolid2y ago
This is amazing..
OrJDev
OrJDev2y ago
ye
OrJDev
OrJDev2y ago
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
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
OrJDev
OrJDev2y ago
ah yes true, should seek for another solution for netlify aswell
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
OrJDev
OrJDev2y ago
cool let us know ryan
ryansolid
ryansolid2y ago
yeah thank you
aquarazorda
aquarazorda2y 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
OrJDev
OrJDev2y ago
You can upgrade solid start to its latest versions, it has been fixed in the nft api usage
aquarazorda
aquarazorda2y ago
I'm using latest version, do I need to add something to vercel adapter or something like that?
OrJDev
OrJDev2y ago
No, just make sure the vercel adapter is also on its latest
aquarazorda
aquarazorda2y ago
both are on 0.2.26 but I'm not using create-jd-app, just in case
aquarazorda
aquarazorda2y 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..
OrJDev
OrJDev2y ago
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
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
aquarazorda
aquarazorda2y 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.
OrJDev
OrJDev2y ago
That’s something that create jd app already does
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server