[Solved] Cannot read property ‘getSourceFile’ of null

[Solved] Cannot read property ‘getSourceFile’ of null:

 

This error occurs due to lot of things, I just explained what happened in my case below, hope it helps some people.

I generated a component named “store component” in two different places using the below comments by mistake,

ng g c store

one is under layout folder and

other one is under layout/homepage folder.

When I first generated ng g c store under layout/homepage it imported store component in layout.module.

When I generated under layout second time, layout.module is not updated as the component name is same.

Now actually I don’t want the store component under layout/homepage/store, so when I deleted and changed the references paths to layout/store, I got this error.

Solution:

I removed store component and it’s references everywhere and build to confirm whether the issue is resolved or not. Issue got resolved.

Now again I created the component only under layout and now everything is fine.

 

Hope it helps!

Leave a Reply