Skip to content
Latchkey

Bun "Cannot find module" / "Could not resolve" in CI

Bun tried to resolve an import and found nothing at that specifier. Either the dependency was never installed in this job, or a relative/aliased path does not point at a real file.

What this error means

A bun run or bun build step fails with "error: Cannot find module \"X\"" or "Could not resolve: \"X\"", naming the import and the file that requested it.

Terminal
error: Cannot find module "zod" from "/home/runner/work/app/src/index.ts"
# or during a build:
error: Could not resolve: "./utils/format"

Common causes

Dependencies were not installed in this job

The job ran bun run without a prior bun install, or node_modules was not restored, so the package is absent.

A wrong relative path or missing alias

A relative import points at a file that does not exist (case or extension), or a tsconfig path alias is not configured for Bun.

How to fix it

Install before running and check the path

  1. Run bun install before any bun run/bun build step.
  2. Verify the import path exists with the exact case and extension.
  3. Configure tsconfig paths so aliased imports resolve.
.github/workflows/ci.yml
- run: bun install --frozen-lockfile
- run: bun run build

Match case-sensitive paths for Linux runners

Linux runners are case-sensitive, so ./Utils/format and ./utils/format differ. Match the file name exactly.

src/index.ts
import { format } from "./utils/format";

How to prevent it

  • Run bun install before any run/build step in CI.
  • Match import case and extension to the real files.
  • Configure tsconfig paths so aliases resolve under Bun.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →