9

I am creating on Drupal 8 module. I have used a custom table to store the data collected from forms. Somehow during installation, tables are not created due to an issue in the install file. Now I have fixed the issue, and I want to install the module again.

How can I re-install a module?

From this and this discussions, I know the Disable module functionality has been removed.

Is there any other way to re-install a module so that its database tables are created?

15

The Devel module can also help here.

It makes a "Reinstall modules" page available at /devel/reinstall, which lets you re-install modules in bulk.

It's also worth mentioning Drush; dis (obviously) doesn't work any more, but pm-uninstall and en still do. And if you have Devel installed, you can invoke a reinstall with

drush dre module1 module2
8

As you said "Disable functionality is removed from Drupal 8" ..

The short answer is - you probably are looking for the "Uninstall" tab found on the "Extend" (Modules) page /admin/modules/uninstall

There is no longer any grey area between a module being on and active vs off and "purged". "Disabled" is no longer a thing. Uninstalling a module means removing all traces of it.

Go to admin/modules/uninstall and uninstall module... Then enabled the module from modules list page. That should install the module again.

For Example ....

Before Installing Ban Module in Drupal 8 ... ban_ip module doesn't exist in database..

enter image description here enter image description here

After Installing Ban Module in Drupal 8... ban_ip table is created and module cannot be disabled but can be uninstalled in admin/modules/uninstall

enter image description here enter image description here enter image description here

Now if you uninstall module.. Table will be removed from database and module can be installed again which will create tables in the database..

enter image description here enter image description here

  • Thanks a lot for such awesome explanation. I checked the list of modules in uninstall tab, but couldn't found my module. If you want to check code here github.com/mohit-rocks/messaging . Currently you can install module and settings related forms are coming. – mohit_rocks May 10 '14 at 9:34
1

Solution 1: Uninstall and Install again manually

Using the Drupal UI:

  • Go to the Extend page from the admin menu
  • Go to the uninstall module page
  • Uninstall the module you wish to
  • Go to the Extend page again (where you have a list of modules)
  • Install the module you just uninstalled

Using Drush (you should try it if you don't use it):

  • drush pm-uninstall MODULE -y && drush pm-enable MODULE -y
  • OR in short drush pmu MODULE -y && drush en MODULE -y

Replace MODULE with the name of your module.

Solution 2: Reinstall using Devel module

Assuming you have the devel module installed.

Using Drupal UI:

  • Visit the path /devel/reinstall
  • Re-install the modules you wish to

Using Drush:

  • drush devel-reinstall MODULE -y
  • OR in short drush dre MODULE -y

Replace MODULE with the name of your module.

0

If nothing else works you can try the below for Drupal 8.

  1. Remove the problematic module files and it's folder

    • rm -rf modules/your_problematic_module
  2. Remove the cached twig templates

    • rm -rf sites/default/files/php
  3. Clear the Drupal cache

NOTE: Make sure to backup the code and Database before doing this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.