Angular "Module build failed" - Fix in CI
The Angular build delegated a file to a loader (TypeScript, SCSS, templates) and the loader threw. The underlying cause is usually a SCSS import, a syntax error, or a missing asset referenced by a component.
What this error means
The build fails with Module build failed and a nested error from the loader (often a SCSS or template error).
Error: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Can't find stylesheet to import.
╷
1 │ @use 'theme';
│ ^^^^^^^^^^^^^Common causes
Stylesheet import error
A component SCSS references a partial or theme path that does not resolve on the runner.
Template or asset reference broken
A templateUrl/styleUrls path is wrong, or an imported asset is missing.
How to fix it
Read the nested loader error
- The real cause is the inner error - fix the SCSS import or template path it names.
// component.scss
@use 'src/styles/theme';Verify component file references
- Confirm templateUrl/styleUrls point at existing files with correct case.
@Component({ templateUrl: './foo.component.html', styleUrls: ['./foo.component.scss'] })How to prevent it
- Build on a case-sensitive filesystem to surface path-case bugs.
- Keep SCSS include paths configured consistently with CI.