0

I'm trying to install modules via Composer. I've set up my composer.json file according to Drupal.org's direction. However, the installed modules are being placed inside of vendor/drupal/. I'm new to Drupal 8, so I wouldn't be surprised if this is a result of a simple mistake. I'll include my composer.json file below:

{
    "repositories": {
        "drupal": {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    },
    "require": {
        "drupal/admin_toolbar": "^1.19"
    },
    "extra": {
        "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/{$name}": ["type:drupal-drush"],
            "modules/custom/{$name}": ["type:drupal-custom-module"],
            "themes/custom/{$name}": ["type:drupal-custom-theme"]
        }
    }
}
  • 4
    You are probably missing dependency for composer/installers and potentially drupal-composer/drupal-scaffold. – user21641 Jul 18 '17 at 15:50
1

As per what Ivan Jeros said, if you add "composer/installers": "^1.2" to your "require" array, it will add a composer extention that maps to the directories you added:

"require": {
        "composer/installers": "^1.2",

Otherwise, it puts everything in /vender/drupal

| improve this answer | |
0

It doesn't sound like your composer.json file is getting read. It's possible having multiple composer files. Are you running your commands from the base folder of your project, beside composer.json.

The download directories can customized to match your Drupal layout. For example, this is a popular configuration from Acquia:

"extra": {
    "installer-paths": {
        "docroot/core": [
            "type:drupal-core"
        ],
        "docroot/modules/contrib/{$name}": [
            "type:drupal-module"
        ],
        "docroot/profiles/contrib/{$name}": [
            "type:drupal-profile"
        ],
        "docroot/themes/contrib/{$name}": [
            "type:drupal-theme"
        ],
        "drush/contrib/{$name}": [
            "type:drupal-drush"
        ]
    },
| improve this answer | |
  • I'm running composer commands from the root directory, and the paths look correct. Also, when I run composer require drupal/<module>, composer adds the module name and version number to the composer.json file, which indicates to me that it is reading it. Unless, there is something wrong with how I'm formatting the "extra" array. – Kellen Jul 18 '17 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.