I have a monorepo with a Hono backend, which exports the Hono app instance from src/index.ts
Deployments of Hono work flawlessly until you start to add local modules outside of index.ts, such as src/lib/auth.ts, for example.
I have my Hono backend organized into sub-folders inside the src directory, containing business logic, authentication service and so on. The only solution I found to this issue for now is to dump them all into a monolithic src/index.ts, which is very far from convenient.
Other user in this forum happened to experience similar problem. Not sure if it may be down to the build tooling im using (tsdown), or the file extensions due to using Typescript but itβs been painful so far.
Hoping u guys can help me out! Happy to give access to the repository.
This is what my file tree looks like, for reference.
2025-08-30T03:48:27.899Z [error] Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/var/task/apps/server/src/lib/auth' imported from /var/task/apps/server/src/lib/context.js
at finalizeResolution (node:internal/modules/esm/resolve:281:11)
at moduleResolve (node:internal/modules/esm/resolve:866:10)
at moduleResolveWithNodePath (node:internal/modules/esm/resolve:990:14)
at defaultResolve (node:internal/modules/esm/resolve:1033:79)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:780:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:704:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:687:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:305:38)
at ModuleJob._link (node:internal/modules/esm/module_job:137:49) {
code: 'ERR_MODULE_NOT_FOUND',
url: 'file:///var/task/apps/server/src/lib/auth'
}
Node.js process exited with exit status: 1. The logs above can help with debugging the issue.
Yeah, Iβm experiencing the same thing on my repo with similar structure. Prod build works locally, even when I ship the index.js file out of my projects working dir.
The index.js file in dist\ after the build has the modules embedded correctly but the serverless function just crashes out, in my case with: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/var/task/apps/server/src/lib/context' imported from /var/task/apps/server/src/index.js
In addition to this, when i test hono in isolation using the tsdown build in docker instance, it works as expected. docker run -it --rm -v $(pwd):/app node:22-bullseye node /app/apps/server/dist/index.js
Hi @rokitg, Iβm sorry you are facing this issue.
Have you referred to the Hono on Vercel and Vercel - Hono guides to see if there are some mismatch in default exports?
If possible, Iβd recommend creating a vc init hono project and see if that works well. Then move your code from the old project gradually to this new project and see what breaks it.
When importing internal TS modules likemyfile.ts, make sure you add a .js extension like import abc from "./myFile.js". This temporarily fixed my problem, but would still love to get a proper bug fix from Vercel SDK team.
@kevin-he in your case is it a mono repo (using turbo)?
My issue seems to come from using a mono repo with a src/server and packages/auth or packages/api, tsdown bundles the outputs into a single index.js file but for some reason vercel is still trying to look for the imports even when embedded by tsdown.
Seems like this might not be a hono issue, it might be with how vercel handles the workspace:* references in turbo. I was able to reproduce this error with Fastify also
Error [ERR_MODULE_NOT_FOUND]: Cannot find module β/var/task/apps/server/node_modules/@test-btstest-bts/api/src/routers/index.tsβ imported from /var/task/apps/server/src/index.js