I recently encountered a similar error. Perhaps this will help solve the problem.
Try deleting the project cache that Unreal Engine uses for temporary files. These are folders such as “DerivedDataCache”, “Intermediate” and “Saved”. Delete them, or move the folder to another location. When opening the project they will be restored.
First, in the DefaultEngine.ini settings you need to set the desired DirectX value.
[/Script/WindowsTargetPlatform.WindowsTargetSettings]
DefaultGraphicsRHI=DefaultGraphicsRHI_DX12