Hono app fails in production on Vercel #81346
Replies: 3 comments
-
Thanks for sharing your setup! Root CauseYour Vercel serverless function is trying to import this path:
But it doesn’t exist in the deployed bundle. This happens because:
✅ Solution Steps1. Move
|
Beta Was this translation helpful? Give feedback.
-
Hi @DoneWithWork I just merged a PR that might help: I used rspack to bundle workspace dependencies and serve the bundled dist through Vercel’s entrypoint at /api/index; I had to build it as CommonJS because some internal deps I use aren’t compatible with ESM. Also, the hono + turborepo example on Vercel is broken as-is (it has no build step and was likely copied from the plain hono example), so it won’t work for a turborepo setup. We should open an issue to get it fixed and improve the docs |
Beta Was this translation helpful? Give feedback.
-
Had the same issue - it appears that I ended up using a bundler (tsdown) in combination with vercel primitives and prebuilt deployment. Solution was inspired by this answer on Stackoverflow. More details about how I applied it to my specific project here: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Hi everyone. I currently have turborepo setup with Next Js, and Hono for the backend. I created a package called @repo/db under internal packages so I can reuse the prisma client generation for both frontend and backend under one schema.ts.
Currently Next js deployment has no issue.
But the Hono one deploy successfully on vercel but it outputs this error
Cannot find module '/var/task/apps/backend/node_modules/@repo/db/src/index.ts' imported from /var/task/apps/backend/api/index.js
This causes the app to crash as I rely on @repo/db for the database.
I have no issue running this locally, only in production.
I have attached a link to the github page where my project lives.
Addtionally, right now it's a bit annoying as to test hono with vercel locally I run vercel dev, but this requires me to link to a vercel account and in doing so I have to set the base directory on vercel to apps/backend, but for some reason after setting this I cannot run vercel dev. Any way round this?
Thanks in advance.
Additional information
https://github.com/DoneWithWork/IoT-Project
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions