Skip to content
Latchkey

Angular "Module not found: Error: Can't resolve" in CI

The Angular build (webpack/esbuild under @angular-devkit/build-angular) could not resolve an import specifier. The path is wrong, the package is not installed, or a case-sensitive path differs between your machine and the Linux runner.

What this error means

ng build fails with "Module not found: Error: Can't resolve './foo' in '/home/runner/work/app/app/src/app'" pointing at a specific import.

ng build
./src/app/app.component.ts:5:0-42
Module not found: Error: Can't resolve './services/user.service' in '/home/runner/work/app/app/src/app'

Common causes

Case-sensitive path mismatch on Linux

macOS and Windows treat file names case-insensitively; the Linux runner does not, so User.service vs user.service fails only in CI.

A missing dependency or a wrong relative path

The imported package is not in the lockfile, or a relative path was renamed/moved without updating the import.

How to fix it

Match the import to the real file name and case

  1. Compare the import string against the actual file name, including case.
  2. Rename the import or the file so they match exactly.
  3. For a package import, confirm it is installed with npm ls <pkg>.
app.component.ts
// file is user.service.ts
import { UserService } from './services/user.service';

Verify path aliases resolve in the build

If you use tsconfig paths, ensure the alias maps to a real directory that exists after install on the runner.

tsconfig.json
"paths": {
  "@app/*": ["src/app/*"]
}

How to prevent it

  • Keep import paths case-exact so Linux runners match your machine.
  • Install all imported packages and commit the lockfile.
  • Validate tsconfig path aliases against real directories.

Related guides

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