While creating a custom module if you gave the wrong module name, When you try to run any terminal command you will get an error like

There are no commands defined in the “setup” namespace

Now I understand the solution from one of the answer in this question.But when I try to change the module again, I am always end up in the same error even after I update everything Or I also tried removing other files. If I keep the registration.php it shows error If I delete the registration file, it works. How can I use the same module again.

  • you need to delete your module entry from setup_module table Commented Jan 10, 2018 at 9:58
  • But I can't found my module in the setup_module table.
    – Abel
    Commented Jan 10, 2018 at 10:05
  • just try with remove var folder and generated folder from root. Commented Jan 10, 2018 at 10:07
  • If you check your module namespace in file app\etc\config.php then available there?
    – Abdul
    Commented Jan 10, 2018 at 10:10
  • No its not available there also.
    – Abel
    Commented Jan 10, 2018 at 10:16

1 Answer 1


Remove extension from the magento 2, you need to do following things.

  1. Identify Magento 2 extension name, you can get name from registration.php.

  2. Remove extension entry from app/etc/config.php (entry identify from step1)

  3. Remove extension entry from setup_module table in magento database. (entry identify from step1)

  4. After remove the things, please also run these commands.

    php bin/magento cache:clean
    php bin/magento cache:flush
    php bin/magento indexer:reindex
    php bin/magento setup:upgrade
    php bin/magento setup:static-content:deploy
  5. Now added all your new file and run command again.

After this you can now used same module name for others.

  • Thanks but what do you mean by extension name here. FYI I am new to magento.
    – Abel
    Commented Jan 10, 2018 at 10:23
  • Extension name specify in registration.php file. Commented Jan 10, 2018 at 10:24
  • <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'Foo_Bar', DIR ); This is the file what is the extension name here.
    – Abel
    Commented Jan 10, 2018 at 10:26
  • here "Foo_Bar" is your extension name, You need to remove this entry from file and database table. Commented Jan 10, 2018 at 10:27
  • You mean Foo_Bar? I checked that in both setup_module table and config file it is not available.
    – Abel
    Commented Jan 10, 2018 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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