Unable to locate component resource error — Angular builds

Abhishek Kothari
2 min readFeb 28, 2021

--

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.htmlwas 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',})

--

--

Abhishek Kothari
Abhishek Kothari

Written by Abhishek Kothari

0 Followers

Full stack engineer with 8+ years of experience build cloud native applications for challenging clients. I build cloud architectures that challenge its creators

No responses yet