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.
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
- Run
bun installbefore anybun run/bun buildstep. - Verify the import path exists with the exact case and extension.
- Configure tsconfig
pathsso aliased imports resolve.
- run: bun install --frozen-lockfile
- run: bun run buildMatch case-sensitive paths for Linux runners
Linux runners are case-sensitive, so ./Utils/format and ./utils/format differ. Match the file name exactly.
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.