Magento Developer Insights
February 7, 2024

How to Remove/Uninstall Magento 2 Extension?

By Liam Ashley
How to Remove/Uninstall Magento 2 Extension?
In Magento 1, if you wanted to remove the extension, you only have to remove module files and special config XML files at app/etc/modules directory, but Magento 2 has a more complex way to remove the extension.

Removing an extension in Magento 2 is more complex than in Magento 1 to ensure system stability, especially in cases with dependencies. There are two main methods to remove an extension in Magento 2: Manual Removal and Removal using Composer (Simple & Complex). Here’s how you can do it:

Manual Removal

If your store does not use Composer, you can remove the extension manually. Follow these steps:

  1. Login to your domain via SSH/CLI and navigate to the root of your store.
  2. Check the status of enabled modules: bashCode kopiërenbin/magento module:status Identify the internal name of the module you wish to remove, for example, uninstallext_Demo.
  3. Disable the module:bashCode kopiërenbin/magento module:disable <Internal Module Name> For example:bashCode kopiërenbin/magento module:disable uninstallext_Demo
  4. Upgrade setup to remove the module from all store activities: bashCode kopiërenbin/magento setup:upgrade
  5. Remove the module directory:bashCode kopiërenrm -rf <Module Directory>
  6. Clean the cache:bashCode kopiërenbin/magento cache:clean
  7. Regenerate static contents:bashCode kopiërenbin/magento setup:static-content:deploy -f

Note: Manual removal might leave some errors unchecked, so using Composer is recommended for extension removal.

Removing with Composer (Simple)

Using Composer is the safest way to remove a Magento 2 extension. If the extension has no dependencies, use the Simple removal method:

  1. Login to your domain via SSH/CLI and navigate to the root of your store.
  2. Check the status of enabled modules: bashCode kopiërenbin/magento module:status Identify the internal name of the module you wish to remove, for example, uninstallext_Demo.
  3. Disable the module:bashCode kopiërenbin/magento module:disable <Internal Module Name> For example:bashCode kopiërenbin/magento module:disable uninstallext_Demo
  4. Upgrade setup to remove the module from all store activities: bashCode kopiërenbin/magento setup:upgrade
  5. Locate the module’s composer.json file: For example, it would be located at /vendor/uninstallext/module-demo/composer.json.
  6. Remove the extension using Composer: bashCode kopiërencomposer remove <composer name> For example:bashCode kopiërencomposer remove uninstallext/module-demo

Note: This method is applicable only when the extension has no dependencies.

Removing with Composer (Complex)

If the extension has dependencies, use the Complex removal method:

  1. Login to your domain via SSH/CLI and navigate to the root of your store.
  2. Check the status of enabled modules: bashCode kopiërenbin/magento module:status Identify the internal name of the module you wish to remove, for example, uninstallext_Demo.
  3. Uninstall the module:bashCode kopiërenbin/magento module:uninstall [options] <internal module name> For example:bashCode kopiërenbin/magento module:uninstall uninstallext_Demo
  4. Optional backup options:
    • Backup database:bashCode kopiërenbin/magento module:uninstall --backup-db
    • Backup media:bashCode kopiërenbin/magento module:uninstall --backup-media
    • Backup code:bashCode kopiërenbin/magento module:uninstall --backup-code
    • Remove all tables created by the module:bashCode kopiërenbin/magento module:uninstall --remove-data
    • Clean static files:bashCode kopiërenbin/magento module:uninstall --clear-static-content
  5. Handle dependencies: If dependencies are found, prepend them to the module name: bashCode kopiërenbin/magento module:uninstall --backup-db --clear-static-content Magento_SampleData Magento_Demo
  6. Complete the removal process:bashCode kopiërenbin/magento module:uninstall

This will automatically put your store in maintenance mode, disable and remove applications, clean the cache, and remove all specified data. Composer will then complete the removal.

We hope this article helps you in the removal process of Magento 2 extensions.

Information checked and edited by Liam Ashley

Last updated: August 9, 2024....
Liam Ashley is a highly skilled e-commerce specialist with a deep expertise in Magento 2. With over a decade of experience in the industry, Liam has become a prominent figure in the e-commerce landscape, known for his innovative solutions and strategic insights. Currently serving as the lead Magento 2 developer
Read more about Liam
Stay in the loop
Now you can update. Receive product updates, new and successful versions from Magstack customers directly in my mailbox.