How to uninstall modules in Magento 2?


Installing module in Magento 2 is far easier than uninstalling Magento 2 module(s) so today we are going to cover how to uninstall Magento 2 modules from your webstore without leaving any trace of that module on your filesystem and database 🙂

Here is the step by step guide to uninstall any third party module from Magento 2 manually.

Step 1: Remove the module Vendor_% from app\etc\config.php

Step 2: Drop module tables or columns from database, please check app\code\Vendor\Module\Setup folder for more information

Step 3: Remove the folder app\code\vendor/%

Step 4: Remove module configuration settings from core_config_data table by running the following query

DELETE FROM core_config_data WHERE path LIKE 'vendor%';

Step 5: Remove module from setup_module table by running the following query

DELETE FROM setup_module WHERE module LIKE 'vendor_%';

Step 6: Run the following command by logging onto your SSH server

php bin/magento setup:upgrade

But if you have installed the module via composer then you can run the following list of commands by SSHing on the box to uninstall third party module

php bin/magento module:uninstall -r {{module_name}}

for example

php bin/magento module:uninstall -r Scommerce_GoogleTagManagerPro

-r flag removes module data

Run the following command once module has been successfully uninstalled.

composer remove {{name of the package}}

for example

composer remove scommerce/googletagmanagerpro

Also run the following commands to clean up db and code -:

php bin/magento setup:upgrade
php bin/magento setup:di:compile

Hope this article helped you in some way. Please leave us your comment and let us know what do you think? Thanks.

5 thoughts on “How to uninstall modules in Magento 2?

  1. if uninstalling a package installed via composer you also need to run
    composer remove vendor/package
    so the actions are

    php bin/magento module:uninstall -r {{module_name}}
    composer remove vendor/package
    php bin/magento setup:upgrade

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.