Have you upgrade your Magento to Magento 2 (ver. 2.0.0) yet? If yes, do you have any troubles with your registered module which is used to work fine before stable release? Unless your module is lucky enough to run well, there are several modules are generated by Mangento 2 with the not- specified error. It seems to be that Magento 2 API is fast changing without a backward compatibility so the Magento 2 extensions may not work well. Consequently, it is required that developers update their module(s) frequently.
Related tutorial: Fixing Magento exception printing is disabled by default for security reasons
In this tutorial, we will learn how to fix error: Magento 2 Setup version for module is not specified, a common error you will encounter when upgrading Magento version or creating new Magento 2 module, or after removing a Magento 2 module.
Change module file/folder permission
Wrong file/folder permission may cause this error, you should try to set proper permission first, run this command in Magento 2 CLI
1 | chmod 775 <module path> -R |
for example:
1 | chmod 775 /magento/app/code/vendorname/modulename -R |
Remove module from app/etc/config.php
If you see the error after removing a module of Magento, then try to remove the module in config.php file located in app/etc/config.php, for example:
1 2 3 4 5 6 7 8 9 10 11 | return array ( 'modules' => array ( 'Magento_Core' => 1, 'Magento_Store' => 1, 'Magento_Theme' => 1, 'Magento_Authorization' => 1, 'Magento_custommodule' => 1, ... ), ); |
Remove the unwanted module (for example: Magento_custommodule ) and save the file. Finally clear cache to see if the error is gone.
Adding registration.php and composer.json
You may encounter this issue when creating a new Magento 2 Module. Assume that you have your module registered in app/etc/config.xml like this:
1 | 'Namespace_Modulename => 1, |
The module
1 | module.xml |
file under app/code/Namespace/Modulename/etc/module.xml:
1 2 3 4 | <?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 you run the module, Magento 2 generates the error below:
1 | "Setup version for module 'Tutorials_Page' is not specified"; |
Now here is how to fix it.
First, try to declare the module in module. xml:
1 2 3 | <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> |
Next, add registration.php and composer.json in your module.
/app/code/Namespace/Module/registration.php
1 2 3 4 5 6 | <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'Namespace_Module', __DIR__ ); |
/app/code/Namespace/Module/composer.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | { "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\\": "" } } } |
After that, you run
1 | php -f bin/magento module:enable --clear-static-content Module_Name |
1 | magento setup:upgrade |
and schema upgrade if applicable by running the command:
1 | php bin/magento setup:upgrade |
Now, you have to clear all caches and var/generation folder.
Login to the back end of Magento 2. On the Admin side bar, navigate to Stores >Configurations > Advanced > Advanced.
Your new module should be listed here and start running without the not- specify error anymore.
Good luck!
1 Comment
Thanks for your tutorial, by adding registration.php and composer.json it works and solved my issue