I installed a local copy of Magento 2. I am facing some problem with custom module.

I followed following file/folder structure

app/code/Ps/HelloWorld/etc/module.xml:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    <module name="Ps_HelloWorld" schema_version="0.0.1" setup_version="0.0.1" />
</config>

Inside this file I have the following: I refreshed the store cache and then I got:

Setup version for module 'Ps_HelloWorld' is not specified.

有帮助吗?

解决方案

Try

php -f bin/magento module:enable --clear-static-content Module_Name
php -f bin/magento setup:upgrade

Assuming that you are run the current master branch and not dev branch

其他提示

In my case it was the file/folder permission of that module.

Apache couldn't read the configuration file.

Apply following permission to your module directory.

chmod 775 <module path> -R

Reference source: https://magentoexplorer.com/magento-2-setup-version-for-module-is-not-specified-how-to-fix (in my case, i got this error when creating a new Magento 2 module)

You may encounter this error because of wrong module file/folder permission, you can change permission for module folder as follow

chmod 775 <module path> -R

There's another possibility that you forgot to add registration.php and composer.json in module. Try to add the following file

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

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

and /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\\": ""
        }
    }
}

Finally run these commands

php -f bin/magento module:enable --clear-static-content Module_Name
magento setup:upgrade

Hope this helps!

An additional scenario where this has come up for me was due to performing a pull on my project's repository and the module had been removed from the file system. While this was intentional, there remained at the time lingering configuration for it in Magento's configuration file.

Removing the reference to the module from app/etc/config.php resolved my issue.

TL;DR

I did first try disabling the module using the CLI's module:disable VendorName_ModuleName command and the response back from the CLI was Unknown module(s): 'VendorName_ModuleName'. I assume this is because it was already missing from the file system. Since there weren't intentions of using the module ever again, manual removal of it from app/etc/config.php at this point seems appropriate anyway.

Open your Database and find the table setup_module.

Your module Ps_HelloWorld should be in this table.

If not found try to enter manually.

I had this same problem and it was because PHP Opcache was enabled and based on my settings any updates to any PHP file did not get updated in the cache.

You can clear opcache by creating a file clear_opcache.php and enter the code below.

<?php
opcache_reset();
?>

Then you can run

php clear_opcache.php

Or in my case I can restart the php-fpm service for RHEL

Centos/RHEL 7

systemctl restart php-fpm

Centos/RHEL 6 or older

service php-fpm restart

You can find other ways to restart php-fpm here https://www.cyberciti.biz/faq/how-to-reload-restart-php7-0-fpm-service-linux-unix/

Problem : the file app/etc/config.php was copied from another magento instance (because of a bad file manipulation). Because of that, I had the same symptoms than described in this question.

The solution was to delete all modules names that wasn't in the instance of Magento where the problem occured, and it worked out fine.

Note that a better solution would have probably been to bin/magento module:status , and then bin/magento module:disable for all the module with problems.

I faced same issue. My setup was through docker, doing php container down, then up cleared cache and resolved the issue.

许可以下: CC-BY-SA归因
scroll top