I had this problem for UE5.2, but regenerating project files didn’t solve it.
Instead I followed:
NiagaraDataInterfacePhysicsAsset.h and GroomComponent.h in Unreal 5.1
I solved it by adding both “HairStrandsCore” and “Niagara” to “PublicDependencyModuleNames” in my .Build.cs file.