UE5.1 Expecting to find a type to be declared in a module rules named '......'

I too had the same problem when I was testing my plugin that I made.

The way to fix it was to move the plugin into the project (ue 5.3.2). It should look roughly like this:

YourProject/
├── Plugins/
│   └── YourPlugin/
│       ├── Binaries/
│       └── ...
├── ...

After moving the plugin, the error disappeared and everything worked correctly.