I had this issue. It arose after I installed a Magento Theme into a subfolder of the root directory of my virtual host (i.e. /Applications/MAMP/htdocs/magento2/mycustomtheme_magento2_quickstart). I then proceeded to run grunt clean
followed by grunt exec:mycustomtheme
within the theme sub-directory, and got the error There are no commands defined in the "dev:source-theme" namespace.
.
I tried removing the /var/generation sub-folder but this did not solve the problem (I did not have a /var/di sub-folder).
I eventually solved it by simply opened my web browser (i.e. Chrome) and went to the subfolder address of my custom theme using my virtual host (i.e. http://local.magento2:8888/mycustomtheme_magento2_quickstart/).
It opened the Magento Installer page. I went through the steps to set it up (i.e. Step 1: Readiness Check, etc).
After it was setup I was able to run grunt clean
followed by grunt exec:mycustomtheme
without that error.