Hi, the same issue happen for me after installing UE5. I went back to try and generate VS files for a UE4.27 project and the issue mentioned occurred.
For me, all I had to do was go back to the UnrealEngine-4.27 install location, and run the UnrealVersionSelector-Win64-Shipping.exe, and the issue was resolved. Hope this helps!