Magento 2.0 – Fix Custom Module Enabling Error

climagento-2.0magento2module

Download

Today I downloaded the Magento 2.0 Full Release from the Magento website. I downloaded the Full Release with Sample Data (ZIP with sample data) and installed it. I wanted to test if my custom module build in RC-1 was still working however when I tried to enable the module I got an error.

Module installation

When I wanted to install my custom module I noticed the app/code directory disappeared and after a few clicks found that this was moved to the vendor directory. I assumed this was done by composer so decided to add my module to the composer.json in the document root. Running composer update installed the module to the vendor directory.

Error

Tried to enable module by executing the following command from my root directory:

PHP -f bin/magento module:enable --clear-static-content Test_Module

http://devdocs.magento.com/guides/v2.0/extension-dev-guide/enable-module.html

Unfortunately, I get the following error; anyone has an idea what goes wrong?

[InvalidArgumentException]
There are no commands defined in the "module" namespace.

Best Answer

Giving full control (read/write/execute) to var and pub directory solved this issue for me.

sudo chmod -R 777 var pub

Or, you may also try running the command using sudo.

sudo php -f bin/magento module:enable --clear-static-content Test_Module