Setup version for module 'Namespace_Modulename' is not specified : Magento 2

Deepak Mankotia picture Deepak Mankotia · Nov 23, 2015 · Viewed 7.3k times · Source

I am creating an module in Magento 2 ( ver. 2.0.0). I have registered my module in app/etc/config.xml

'Namespace_Modulename => 1,

My module.xml file under app/code/Namespace/Modulename/etc/module.xml

module.xml :

<?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="Namespace_Modulename" setup_version="2.0.1"/> 
</config>

When I run my module Magento 2 generate below error :

Setup version for module 'Namespace_Modulename' is not specified

My module was working fine before stable release, after upgraded to stable release I start getting this error. I searched lot on google before adding here, got some results but none of then working for me.

Kindly guide me where I am doing wrong. Thanks in advance.

Answer

Reena Parekh picture Reena Parekh · Nov 23, 2015

Try this in module.xml:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
  <module name="Namespace_Modulename" schema_version="2.0.1" setup_version="2.0.1"/> 
</config>

Add registration.php and composer.json in your module.

/app/code/Namespace/Module/registration.php

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Namespace_Module',
    __DIR__
);

/app/code/Namespace/Module/composer.json

{
    "name": "namespace/module",
    "description": "namespace",
    "require": {
      "php": "~5.5.0|~5.6.0|~7.0.0",
      "magento/framework": "100.0.*",
      "magento/module-ui": "100.0.*",
      "magento/module-config": "100.0.*",
      "magento/module-contact": "100.0.*"    
    },
    "type": "magento2-module",
    "version": "100.0.0",
    "license": [
        "OSL-3.0",
        "AFL-3.0"
    ],
    "extra": {
        "map": [
            [
                "*",
                "Namespace/Module"
            ]
        ]
    },
    "autoload": {
        "files": [ "registration.php" ],
        "psr-4": {
            "namespace\\module\\": ""
        }
    }
}

Now run magento setup:upgrade and schema upgrade if applicable.

Now clear all caches and var/generation folder. Login to admin panel > Stores > Configuration > Advanced > Advanced. Your module should be listed here now.