Can't find stylesheet to import. Angular 17
Asked Answered
P

3

8

i'm trying to import angular material theming in the styles.scss file, But when i run ng serve, it throws the "Can't find stylesheet to import." Error.

Below is my import

@import '@angular/material/theming';

enter image description here I'm currently using Angular cli 17.

I've tried importing using the @use, but the error was the same. And i tried to change the path of the import to the node_module/@angular/material/theming.

Parathion answered 8/1, 2024 at 23:48 Comment(3)
Please don't add irrelevant tags. angularjs is (as the tag information says) about AngularJS v1.9 and less. angular is a different framework, and exists for versions 2 and above.Jovian
Also, Please do not upload images of code/data/errors.Jovian
Didn't know that, sorry!Parathion
C
-1

try @import '~@angular/material/theming'; Refer this link

Casemaker answered 9/1, 2024 at 7:1 Comment(1)
no difference with this changeDraconic
M
4

Here is how I solved it. In your global stylesheet, like styles.scss:

  1. make sure you have @use '@angular/material' as mat;, and it is before all @include statements.
  2. remove @import '@angular/material/theming';
  3. Replace @include mat-core; with @include mat.core;
  4. If present, replace @include mat.all-legacy-component-themes($the-theme-you-use); with @include mat.all-component-themes($the-theme-you-use);

Make sure that $the-theme-you-use exists.

Musteline answered 29/7, 2024 at 13:46 Comment(0)
S
3

No need for `@import '@angular/material/theming'; in Angular 17 any more. See official documentation here

Syverson answered 25/2, 2024 at 17:50 Comment(0)
C
-1

try @import '~@angular/material/theming'; Refer this link

Casemaker answered 9/1, 2024 at 7:1 Comment(1)
no difference with this changeDraconic

© 2022 - 2025 — McMap. All rights reserved.