There are no commands defined in the "setup" namespace : Magento 2
Please mention setup_version
in your module.xml file.
Your module.xml file looks like:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Vendor_Module" setup_version="1.0.0"/>
</config>
You need to give full permission to both var and pub folders recursively.
sudo chmod -R 777 var pub
I wanted to add an answer because the others doens't cover all the problems that could generate this error :
There are no commands defined in the "setup" namespace.
in general.
This error could be caused by permission as said in others answer but we could have other scenario.
- The absense of : etc/module.xml
- An error in /etc/module.xml or in /etc/di.xml or others xml extensions under /etc
If you know other scenario please comment this answer.
Hope this help.
Giving full control (read/write/execute) to var and pub directory should solve this issue.
sudo chmod -R 777 var pub
You may also try running the command using sudo.
sudo php bin/magento setup:upgrade