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.
error: Cannot find module "@acme/shared" from "apps/web/src/index.ts"
# @acme/shared is a workspace member that was not linkedCommon 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
- Run
bun installat the monorepo root so all members are linked. - Confirm the
workspacesglobs cover every package directory. - Reference workspace deps as
workspace:*in members.
{
"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.
- uses: actions/checkout@v4
with:
fetch-depth: 0How 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.