The following module is missing from the file system

If you are getting the error message:

The following module is missing from the file system: <em class="placeholder"> <<module name>> </em>. In order to fix this, put the module back in its  original location. For more information, see <a href="https://www.drupal.org/node/2487215">the documentation page</a>.
M=module_missing_message_fixer # shorthand
  • For each site:
S=/path/to/site/root
dsite add $S $M; drush en $M -y -r $S
  • visit site/admin/config/system/module-missing-message-fixer and remove unwanted entries
drush dis $M -r $S -y; drush pm-uninstall $M -r $S -y; dsite remove $S $M
  • An alternative way of removing entries is directly with SQL. The first statement checks the entry is there.
F=module_name
drush sql-query -r $S "SELECT name, type FROM system WHERE name = '"$F"';"
drush sql-query -r $S "DELETE FROM system WHERE name = '"$F"' AND type = 'module';"