Hello friends at Vercel.
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.
src/│ │ │ ├── index.ts # Main hono entry point (had to consolidate everything here, lol)│ │ │ ├── db/│ │ │ │ ├── index.ts # Database connection│ │ │ │ └── schema/ # Drizzle ORM schemas│ │ │ │ ├── auth.ts # User, session, account tables│ │ │ │ └── todo.ts # Todo table schema│ │ │ ├── lib/│ │ │ │ ├── auth.ts # Better-auth configuration│ │ │ │ ├── context.ts # Request context creation│ │ │ │ └── orpc.ts # ORPC server setup│ │ │ └── routers/│ │ │ ├── index.ts # Main API router (health, private data)│ │ │ └── todo.ts Here are my logs:
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.