Skip to content
Latchkey

Bun workspaces package not found / resolution in CI

Bun links workspace members from the workspaces globs in the root package.json. In CI a member fails to resolve when the install ran outside the root, the glob misses the package, or a sparse checkout omitted it.

What this error means

An import of an internal workspace package fails with "Cannot find module", or bun install does not link a member, in a monorepo that works locally.

Terminal
error: Cannot find module "@acme/shared" from "apps/web/src/index.ts"
# @acme/shared is a workspace member that was not linked

Common causes

bun install ran outside the workspace root

Running bun install in a subdirectory instead of the repo root means Bun never links the workspace members.

The workspaces glob or checkout excludes the member

A workspaces glob that does not cover the package, or a sparse/shallow checkout that omits it, leaves the member unresolved.

How to fix it

Install from the repo root

  1. Run bun install at the monorepo root so all members are linked.
  2. Confirm the workspaces globs cover every package directory.
  3. Reference workspace deps as workspace:* in members.
package.json
{
  "workspaces": ["apps/*", "packages/*"]
}

Check out the full tree in CI

Ensure the checkout includes all workspace directories so Bun can find and link every member.

.github/workflows/ci.yml
- uses: actions/checkout@v4
  with:
    fetch-depth: 0

How to prevent it

  • Run bun install at the workspace root in CI.
  • Keep workspaces globs covering every package directory.
  • Avoid sparse checkouts that drop workspace members.

Related guides

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