Skip to content

Hono server crashes on vercel #725

@Anakin100100

Description

@Anakin100100

I created a new project using

bun create better-t-stack@latest temp-monitor --frontend tanstack-router --backend hono --runtime bun --api orpc --auth better-auth --payments none --database postgres --orm drizzle --db-setup neon --package-manager bun --no-git --web-deploy none --server-deploy none --install --addons biome turborepo --examples todo

And tried to deploy both apps on vercel separately. The frontend works ok, but the backend built using hono crashes every time with this error

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/var/task/apps/server/node_modules/@temp-monitor/api/src/context.ts' imported from /var/task/apps/server/src/index.js
    at finalizeResolution (node:internal/modules/esm/resolve:280:11)
    at moduleResolve (node:internal/modules/esm/resolve:870:10)
    at moduleResolveWithNodePath (node:internal/modules/esm/resolve:996:14)
    at defaultResolve (node:internal/modules/esm/resolve:1039:79)
    at #cachedDefaultResolve (node:internal/modules/esm/loader:757:20)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:734:38)
    at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:317:38)
    at #link (node:internal/modules/esm/module_job:208:49)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5) {
  code: 'ERR_MODULE_NOT_FOUND',
  url: 'file:///var/task/apps/server/node_modules/@temp-monitor/api/src/context.ts'
}
Node.js process exited with exit status: 1. The logs above can help with debugging the issue.

Vercel uses the default build settings for hono

Image

Here are build logs without caching:

19:36:47.289 Running build in Washington, D.C., USA (East) – iad1
19:36:47.289 Build machine configuration: 2 cores, 8 GB
19:36:47.299 Cloning github.com/Anakin100100/temp-monitor (Branch: main, Commit: b7f63c6)
19:36:47.300 Skipping build cache, deployment was triggered without cache.
19:36:48.075 Cloning completed: 775.000ms
19:36:48.436 Running "vercel build"
19:36:48.830 Vercel CLI 50.0.1
19:36:48.972 > Detected Turbo. Adjusting default settings...
19:36:49.566 Running "install" command: `bun install`...
19:36:49.601 bun install v1.3.3 (274e01c7)
19:36:52.324 
19:36:52.324 + @types/[email protected]
19:36:52.324 + [email protected]
19:36:52.325 + [email protected]
19:36:52.325 + @orpc/[email protected]
19:36:52.326 + @orpc/[email protected]
19:36:52.327 + @orpc/[email protected]
19:36:52.327 + [email protected]
19:36:52.327 + [email protected]
19:36:52.328 + [email protected]
19:36:52.328 + [email protected]
19:36:52.328 
19:36:52.328 690 packages installed [2.66s]
19:36:53.047 
19:36:53.048 Attention:
19:36:53.048 Turborepo now collects completely anonymous telemetry regarding usage.
19:36:53.049 This information is used to shape the Turborepo roadmap and prioritize features.
19:36:53.049 You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
19:36:53.049 https://turborepo.com/docs/telemetry
19:36:53.049 
19:36:53.096 • Packages in scope: server
19:36:53.096 • Running build in 1 packages
19:36:53.096 • Remote caching enabled
19:36:53.130 server:build: cache bypass, force executing a571aa628df4d572
19:36:53.133 server:build: $ tsdown
19:36:53.201 server:build: �[34mℹ�[39m tsdown �[2mv0.16.8�[22m powered by rolldown �[2mv1.0.0-beta.52�[22m
19:36:53.286 server:build: �[34mℹ�[39m Using tsdown config: �[4m/vercel/path0/apps/server/tsdown.config.ts�[24m
19:36:53.289 server:build: �[34mℹ�[39m entry: �[34msrc/index.ts�[39m
19:36:53.290 server:build: �[34mℹ�[39m tsconfig: �[34mtsconfig.json�[39m
19:36:53.290 server:build: �[34mℹ�[39m Build start
19:36:53.392 server:build: �[34mℹ�[39m �[2mdist/�[22m�[1mindex.mjs�[22m  �[2m490.81 kB�[22m �[2m│ gzip: 112.05 kB�[22m
19:36:53.393 server:build: �[34mℹ�[39m 1 files, total: 490.81 kB
19:36:53.393 server:build: �[32m✔�[39m Build complete in �[32m101ms�[39m
19:36:53.449 
19:36:53.449  WARNING  finished with warnings
19:36:53.450 
19:36:53.450 Warning - the following environment variables are set on your Vercel project, but missing from "turbo.json". These variables WILL NOT be available to your application and may cause your build to fail. Learn more at https://turborepo.com/docs/crafting-your-repository/using-environment-variables#platform-environment-variables
19:36:53.450 
19:36:53.450 [warn] server#build
19:36:53.450 [warn]   - DATABASE_URL 
19:36:53.450 [warn]   - BETTER_AUTH_SECRET 
19:36:53.450 [warn]   - BETTER_AUTH_URL 
19:36:53.451 [warn]   - CORS_ORIGIN 
19:36:53.451 
19:36:53.451   Tasks:    1 successful, 1 total
19:36:53.451  Cached:    0 cached, 1 total
19:36:53.451    Time:    393ms 
19:36:53.451 Summary:    /vercel/path0/.turbo/runs/36qjUleivmCtLgubwgyA5axC4pJ.json
19:36:53.451 
19:36:53.850 Using TypeScript 5.9.3 (local user-provided)
19:37:27.509 Build Completed in /vercel/output [38s]
19:37:27.840 Deploying outputs...
19:37:33.839 Deployment completed
19:37:34.724 Creating build cache...
19:37:47.937 Created build cache: 13.203s
19:37:47.938 Uploading build cache [131.70 MB]
19:37:49.836 Build cache uploaded: 1.907s`

I hope this is helpful for you when fixing this issue, because the project is really cool.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions