Reinstall default config from module without having to uninstall and install module - Drupal 8/9

Uninstall and install module may delete configuration along with contents. This will allow you to recreate or install everything in the config/install folder of your custom module:

\Drupal::service('config.installer')->installDefaultConfig('module', $module);

*where $module is your module machine name.

This can be run with drush eval or drush php.


drush php-eval "\Drupal::service('config.installer')->installDefaultConfig('module', 'my_module_name');"