Drupal supports multiple module discovery locations. Modules can be placed in the following directories and discovered:
- /profiles/CURRENT PROFILE/modules
- /sites/all/modules
- /modules
- /sites/default/modules
- /sites/example.com/modules
The \Drupal\Core\Extension\ExtensionDiscovery class handles the discovery of extensions by type. It will iteratively scan each location and discover modules that are available. The discovery order is important. If the same module is placed in /modules, but also in the sites/default/modules directory, the latter will take precedence.