Skip to main content

Drupal: Fixing the dreadful: Import failed due to the following reasons (message) - Unable to install module

Every now and then when you switch branches or working on a new feature and your current branch is behind or uses different configuration you might end up with a message like this when you do a "drush cim"

In order to resolve an issue like this you must understand the error message :)

First make sure that your composer.json file includes the missing modules for this example: jquery UI Autocomplete and jQuery UI Menu are the missing modules.

If you do not have them into your composer.json file then you have to require them like this :

composer require drupal/jquery_ui_menu drupal/jquery_ui_autocomplete

After that check in your active config folder the status of the core.extension.yml file. You will notice that these 2 modules are missing. Now because these 2 modules are "active" into core.extension.yml this is that matters most. It does not matter if they are active (enabled) or not within your database.

So in order to proceed with your configuration import you need to add them in the core.extenstion.yml file.

  jquery_ui_datepicker: 0
  jquery_ui_slider: 0
  jquery_ui_touch_punch: 0
  jquery_ui_autocomplete: 0
  jquery_ui_menu: 0
  jsonapi: 0
  jsonapi_extras: 0

Now that they are in, you can try again running drush cim.

Please notice that this affects once your core.extension.yml file and depending your gitflow or development process this is something that you might need to do or reconfigure again in the future.