GameModeBase.h inaccessible even though its included in the header file

Did you include it via

#include "GameFramework/GameModeBase.h"

Do your dependencies in the build.cs file have the “Engine” module?