Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve error in HostResourceResolver?

What would be the steps to resolve this error?

ERROR in HostResourceResolver: could not resolve styles.css in context of C:/Users/shema/Desktop/angular/RP/ResourcePlanning/src/app/addproject/addproject.component.ts)

like image 975
Shema Jacob Avatar asked Apr 01 '20 08:04

Shema Jacob


3 Answers

HostResourceResolver happens when the name of your component is wrong.

form.component.html

Wrong name, need to correct for form-dialog.component.html to resolve.

and my templateUrl is form-dialog.component.html.

@Component({
  selector: 'app-form-dialog',
  templateUrl: './form-dialog.component.html',
  styleUrls: ['./form-dialog.component.scss']
})
export class FormDialogComponent implements OnInit {}
like image 177
Braian Silva Avatar answered Oct 04 '22 11:10

Braian Silva


For anyone facing this issue: it could be a number of reasons but usually it is because the file cannot be read by the angular compiler or there is a syntax error.

For me, I was including a typescript only component within the HTML of another component (the app component) but had a templateUrl property mentioned with a blank value.

This breaks the build process - but does not mention any file name. I fixed the issue by replacing templateUrl with template.

like image 25
Jonathan Cardoz Avatar answered Oct 04 '22 12:10

Jonathan Cardoz


Please show the component code, especially @Component part. Typically you would have something like this:

@Component({
    selector: 'app-add-project',
    templateUrl: './add-project.component.html',
    styleUrls: ['styles.css']
})
export class AddProjectComponent  implements OnInit {
....

It looks like Angular cannot resolve styles.css. You probably need to specify relative path to the file

like image 38
Felix Avatar answered Oct 04 '22 10:10

Felix