安装失败 - 尝试使用 composer 在 Drupal8 上安装模块

Installation failed - trying to install modules on Drupal8 using composer

所以我在 drupal8 环境中尝试安装的任何模块都收到相同的错误消息。 我一直在整理文件和文件夹,所以我确定我弄坏了一些东西。

是否可以在任何地方查看 drupal 日志文件以获取有关错误的更多帮助,或者有人知道此错误的原因吗?

composer require drupal/Astrology
Using version ^1.4 for drupal/astrology
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing drupal/astrology (1.4.0): Loading from cache
Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.
Writing lock file
Generating autoload files
29 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

Installation failed, reverting ./composer.json to its original content.

                                            
  [RuntimeException]                        
  does not exist and could not be created.  
                                            

这是完整的 composer.json 文件:

{
    "name": "drupal/recommended-project",
    "description": "Project template for Drupal 8 projects with a relocated document root",
    "type": "project",
    "license": "GPL-2.0-or-later",
    "homepage": "https://www.drupal.org/project/drupal",
    "support": {
        "docs": "https://www.drupal.org/docs/user_guide/en/index.html",
        "chat": "https://www.drupal.org/node/314178"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    ],
    "require": {
        "composer/installers": "^1.2",
        "drupal/admin_toolbar": "^2.3",
        "drupal/bootstrap_barrio": "^5.1",
        "drupal/coffee": "^1.0",
        "drupal/core-composer-scaffold": "^8.8",
        "drupal/core-project-message": "^8.8",
        "drupal/core-recommended": "^8.8",
        "drupal/devel": "^4.0",
        "drupal/entity_delete": "^1.6",
        "drupal/feeds": "^3.0@alpha",
        "drupal/feeds_tamper": "^2.0@beta",
        "drupal/flexslider_fields": "^2.0",
        "drupal/fontawesome": "^2.17",
        "drupal/gdoc_field": "^1.1",
        "drupal/migrate_plus": "^5.1",
        "drupal/migrate_tools": "^5.0",
        "drupal/migrate_upgrade": "^3.2",
        "drupal/paragraphs": "^1.12",
        "drupal/pathauto": "^1.8",
        "drupal/pdf_reader": "1.x-dev",
        "drupal/superfish": "^1.4",
        "drupal/tablefield": "^2.1",
        "drush/drush": "^10.3"
    },
    "conflict": {
        "drupal/drupal": "*"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "config": {
        "sort-packages": true
    },
    "extra": {
        "drupal-scaffold": {
            "locations": {
                "web-root": ""
            }
        },
        "installer-paths": {
            "core": [
                "type:drupal-core"
            ],
            "libraries/{$name}": [
                "type:drupal-library"
            ],
            "modules/contrib/{$name}": [
                "type:drupal-module"
            ],
            "profiles/contrib/{$name}": [
                "type:drupal-profile"
            ],
            "themes/contrib/{$name}": [
                "type:drupal-theme"
            ],
            "drush/Commands/contrib/{$name}": [
                "type:drupal-drush"
            ],
            "modules/custom/{$name}": [
                "type:drupal-custom-module"
            ],
            "themes/custom/{$name}": [
                "type:drupal-custom-theme"
            ]
        },
        "drupal-core-project-message": {
            "include-keys": [
                "homepage",
                "support"
            ],
            "post-create-project-cmd-message": [
                "<bg=blue;fg=white>                                                         </>",
                "<bg=blue;fg=white>  Congratulations, you’ve installed the Drupal codebase  </>",
                "<bg=blue;fg=white>  from the drupal/recommended-project template!          </>",
                "<bg=blue;fg=white>                                                         </>",
                "",
                "<bg=yellow;fg=black>Next steps</>:",
                "  * Install the site: https://www.drupal.org/docs/8/install",
                "  * Read the user guide: https://www.drupal.org/docs/user_guide/en/index.html",
                "  * Get support: https://www.drupal.org/support",
                "  * Get involved with the Drupal community:",
                "      https://www.drupal.org/getting-involved",
                "  * Remove the plugin that prints this message:",
                "      composer remove drupal/core-project-message"
            ]
        }
    }
}

谢谢 马克

您的问题有简单的解决方案。添加 web-root 文件夹。公平地说,将供应商存储在 Web 文件夹之外是一种很好的做法。

这是您应该如何操作的示例(您也可以将 web 更改为 docroot 或您喜欢的任何其他内容):

    "extra": {
    "drupal-scaffold": {
        "locations": {
            "web-root": "./web"
        }
    },
    "installer-paths": {
        "web/core": [
            "type:drupal-core"
        ],
        "web/libraries/{$name}": [
            "type:drupal-library"
        ],
        "web/modules/contrib/{$name}": [
            "type:drupal-module"
        ],
        "web/profiles/contrib/{$name}": [
            "type:drupal-profile"
        ],
        "web/themes/contrib/{$name}": [
            "type:drupal-theme"
        ],
        "drush/Commands/contrib/{$name}": [
            "type:drupal-drush"
        ],
        "web/modules/custom/{$name}": [
            "type:drupal-custom-module"
        ],
        "web/themes/custom/{$name}": [
            "type:drupal-custom-theme"
        ]
    },

您可能注意到 drush 命令在 web 文件夹之外。存储构建脚本、服务器挂钩、补丁等的方式相同