Cannot find module from sibling workspace (build order) in CI
A package imported a sibling workspace package whose build had not run yet, so the compiled entry point does not exist. The dependency graph was not respected by the build order.
What this error means
A build or test fails with "Cannot find module @acme/ui" or "Cannot find module \".../dist/index.js\"" even though the package exists in the workspace.
pnpm
Error: Cannot find module '@acme/ui'
Require stack:
- /workspace/apps/web/src/main.ts
# @acme/ui/dist was never builtCommon causes
Dependency not built first
The consumer ran before the sibling package produced its dist output, so the entry point is missing.
Build does not respect topology
A flat or parallel build script ignores the inter-package dependency graph.
Wrong main/exports path
The package points at a dist file that the build never emits.
How to fix it
Build in topological order
- Use a tool that respects the dependency graph so dependencies build first.
Terminal
# turbo respects dependsOn ^build
turbo run build
# or pnpm topological order
pnpm -r --workspace-concurrency=1 buildDeclare build dependencies
- Add dependsOn ["^build"] (Turbo) or correct dependency edges so order is enforced.
How to prevent it
- Drive builds through a topology-aware runner (Turbo/Nx dependsOn) so dependency packages always build before their consumers.
Related guides
Circular dependency between workspaces in CIFix circular dependencies between workspace packages in CI. Two packages depend on each other, so the build o…
pnpm workspace package not found (workspace:*) in CIFix pnpm "no matching version found for workspace:*" in CI. A workspace dependency name does not match any pa…
Workspace phantom dependency / hoisting error in CIFix workspace phantom dependency errors in CI. Code imported a package it never declared, which works under h…