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.
./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
- Compare the import string against the actual file name, including case.
- Rename the import or the file so they match exactly.
- For a package import, confirm it is installed with
npm ls <pkg>.
// 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.
"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.