One thing is important, DO NOT click build in the toolbar directly. This way the compiler cannot locate some headers.
I solved my problem by RIGHT CLICKING on the UE4(UE5) project and then clicking build option that pops up.
(right, I am an idiot… I clicked the build button in the toolbar)