Any change made to build.cs results in compile error (tried UE5.1 and UE5.2)

this is how to detach

here is a segment of code for the enhanced input module

// Copyright Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;

public class yourGameName: ModuleRules
{
	public yourGameName(ReadOnlyTargetRules Target) : base(Target)
	{
		PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "HeadMountedDisplay", "EnhancedInput" });

	}
}

I’ve also seen that some people put “EnhancedInput” in the private dependencies

Seems in your code you are missing

using UnrealBuildTool;

You would need to put in the namespace before the public & private dependency Module names for them to register correctly hence the error.