How to Uninstall and Remove a Magento 2 Extension
Once you install Magento 2, usually you require to install Magento 2 extensions to build a fully functional store. As the time and website grow, you realize that some of the extensions are not best-fit or some forfeit their usefulness or their functionality is no longer required or you require reinstallation, it’s time when you want to uninstall and remove a Magento 2 extension.
Moreover, when there are a large number of extensions in Magento 2 store, it affects various factors adversely, although offering its functionality. Such factors are the increase in loading time, conflictions occurring between two extensions, SQL errors due to third-party extensions. Due to these reasons, you may require to uninstall a Magento 2 extension.
Also, you may want to remove a module that offers the same functionality as an already installed extension.
A large number of extensions also results in the complexity of store structure. Isn’t this enough reason to remove the unwanted extensions? Let’s see how the process can be done.
Uninstalling an extension should be a simple task but not always. They leave behind data in a number of places in the database which occupy unnecessary space and affects the store’s performance. Today, I have come up with 2 methods to uninstall and remove a Magento 2 extension.
The extension uninstallation method depends on its installation process.
Method 1: Uninstall and Remove a Magento 2 Extension Manually
Step 1: Connect via SSH to the root of your Magento installation (the folder that has the app folder in it) and go through the list of all extensions including their enable/disable status
1 |
php bin/magento module:status |
Step 2: Disable the extension by executing the given commands:
1 2 |
php bin/magento module:disable <ExtensionProvider_ExtensionName> --clear-static-content php bin/magento setup:upgrade |
Step 3: Remove the extension files
1 2 |
cd app/code/<ExtensionProvider>/ rm -rf <ExtensionName> |
Note: Don’t make the mistake to remove the shared extension from a common vendor. You may end up deleting the dependency pack that serves as a base for all their extensions.
Example: Suppose you are using Magento 2 Flat Rate Shipping Extension by Meetanshi and you want to uninstall it and remove all associated files:
1 2 3 4 |
php bin/magento module:disable Meetanshi_Flatshipping --clear-static-content php bin/magento setup:upgrade cd app/code/Meetanshi/ rm -rf Flatshipping |
Method 2: Composer Uninstallation Method
Step 1: Connect via SSH to the root of your Magento installation (the folder that has the app folder in it) and check the list of all modules including their enable/disable status
1 |
php bin/magento module:status |
Step 2: Disable the module by executing the given commands:
1 2 3 |
php bin/magento module:disable <ExtensionProvider_ExtensionName> --clear-static-content php bin/magento setup:upgrade composer remove VendorName/VendorExtensionRepository |
- You can find the exact match for ExtensionProvider and ExtensionName in composer.json file associated with the module.
- Also, you can get VendorName and VendorExtension in composer.json file associated with the extension.or under yourmagentoinstallation/com/vendor/<VendorName>/<VendorExtension>
- If you are asked for composer username and password while the uninstallation process, navigate to var/composer_home/auth.json.
Example: Let’s take the example of the same extension for this method as well. First of all, disable the extension, run the setup upgrade and finally remove the files via composer:
1 2 3 |
php bin/magento module:disable Meetanshi_Flatshipping --clear-static-content composer remove meetanshi/m2-meetanshi-flatshipping php bin/magento setup:upgrade |
Note: Along with removing the extension, you would want to remove the extension attribute or product attribute that might be created. If so, remove the extension attribute from the table with this method:
go to phpmyadmin -> search table “eav_attribute”
and remove that extension attribute from the table
I have tried to present the easy ways to uninstall a Magento 2 module. Still, if you face any difficulty in the process, please mention the doubts in the comments section below. I’d be happy to help.
Also, you can always follow the Magento DevDoc to uninstall modules.
Rate the blog with 5 stars to appreciate the work 🙂
Facing issues with your Magento store or want to add new features? Our Magento Development Services are here to help!
Sanjay Jethva
Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe.
His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.
5 Comments
I can sucessfully disable the module but I can not remove it.
The files are still in vendor/
Disable Module Successful:
bin/magento module:disable Mageplaza_Webhook
The following modules have been disabled:
– Mageplaza_Webhook
Remove Not Succesfull:
composer remove Mageplaza_Webhook
mageplaza_webhook is not required in your composer.json and has not been removed
Package “mageplaza_webhook” listed for update is not installed. Ignoring.
Nothing to install or update
Please advise. Thanks!
Hello,
There is a mistake in the command that you have run.
What you have to do is instead of composer command to install the extension, you have to replace composer require with composer remove.
Still, if you find an issue, follow the below steps:
1. Open the composer file of the installed extension vendor.
2. Copy the name defined in the composer file
3. Run composer remove
That’s it.
i did not enable this so i need more info as to how to disable it.
If you don’t have any extension installed on your Magento Store then you don’t need to worry about uninstalling.
Thanks for sharing this post. Keep up the good work!
You can also disable/enable Magneto 2 extensions by changing the value of module from 1 to 0 in app/etc/config.php.