Unable to locate component resource error — Angular builds
I came across this weird error some time back when one of my clients provided me with an Angular repository that was not getting built. The concerned developer had submitted code to the client saying that all of it was good and demonstrated too. Nothing to worry — Right? :)
That was not the case — The developer happened to change the name of the files — Say abc.component.html
was changed to Abc.component.html
Just the name was changed and nothing else — Git does not care if you change just the case in the file name — Angular builds started failing with the error
Unable to locate component resource: /path/to/the/component/html/file
This error was confusing at first as the HTML file itself was all good — The problem turned out to be that the selector in the TS
file -
@Component({
selector: 'app-abc',templateUrl: './abc.component.html',})
was never changed. This meant that Angular was unable to find the HTML file that it required. Changing the above selector to the right component file name solved the issue !
@Component({selector: 'app-abc',templateUrl: './Abc.component.html',})