Angular "Module not found: Error: Can't resolve" in CI
Angular's bundler tried to resolve an import and found nothing at that specifier. In CI this is usually a missing dependency, a wrong relative path, or a filename whose casing differs from the import on a case-sensitive runner.
What this error means
ng build fails with "Module not found: Error: Can't resolve 'X' in '/path'", often for a package or a relative import that resolves on a developer's case-insensitive disk.
./src/app/app.component.ts:3:0-42 - Error: Module not found: Error:
Can't resolve './shared/Button' in '/home/runner/work/app/app/src/app'Common causes
A dependency is missing from package.json
The import is satisfied locally by a stray install but is not a declared dependency, so a clean CI install cannot resolve it.
Wrong path or filename casing
A relative path is wrong, or the import casing differs from the file (Button vs button), which fails on a case-sensitive Linux runner.
How to fix it
Add the dependency or fix the path
- For a package, add it to package.json and reinstall.
- For a relative import, correct the path and match the file casing exactly.
- Re-run the build.
import { Button } from './shared/button'; // match the real filename casingMatch casing for case-sensitive runners
Rename either the file or the import so casing matches, since Linux CI is case-sensitive where macOS/Windows is not.
How to prevent it
- Declare every import as a real dependency in package.json.
- Keep import paths and filename casing identical.
- Develop or lint on a case-sensitive setup to catch casing drift.