Drupal to organize all modules under the /modules/contrib directory
Sometimes when we update the drupal major version from 8.x to 9.x or even to 10.x, we will have problems with the modules, for example, there might be multiple installations of the single module, that is, you wil find the modules in two directories,
/modules/modulename
/modules/contrib/modulename
This is because the old module is installed manually and the contrib/ is installed by composer, to solve the problem, you have to do the following,
remove the /modules/modulename and run
vendor/bin/drush cr
to rebuild the cache registry, this will ensure the module is actually called from /modules/contrib/modulename.
Incase your module is not found in the /modules/contrib directory, you will need to run
composer require drupal/modulename
and then remove the module/modulename, run drush cr again.