-1

I want to manage my modules with composer, so I created a composer.json file in my sites/my_site directory that looks like this:

{
    "repositories": {
        "drupal": {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    },
    "require": {
        "composer/installers": "~1.0",
        "drupal/addtoany": "^1.8",
        "drupal/workbench": "^1.0",
    },
    "extra": {
        "installer-paths": {
            "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"]
        }
    }
}

The problem is that when I run "composer install" or "composer update", I get a "core" directory with Drupal core created in my sites/my_site directory. Is there any way to avoid pulling in the core and only get the modules using composer from my sites/my_site directory?

  • Shouldn't composer be in the root directory? – Kevin Nov 9 '17 at 21:11
  • It should. In my case though I am using a shared Drupal install and only have permissions to my sites/my_site directory, so want to manage the dependencies from there. – Maxim Neaga Nov 9 '17 at 21:20
1

Did not try this personally, but should work. Add this to your composer.json root:

"name": "drupal/core", "version": "8.4.2",

(adjust version number to your installed core version)

Be aware though this is not considered a clean solution, the recommended way is for drupal composer is "all or nothing". And I really recommend the "all" way, you do get the comfort of dependency and version and patch management.

More info about this hack: https://github.com/composer/composer/issues/5024

  • Tried that, but for some reason it now fails claiming that drupal/core dependency is missing: Problem 1 - drupal/migrate_source_csv 2.0.0 requires drupal/core ~8.1 -> satisfiable by drupal/core[8.1.0, 8.1.0-beta1, ...] – Maxim Neaga Nov 9 '17 at 21:15
  • Looks like adding version made it work: "version": "8.4.2", – Maxim Neaga Nov 9 '17 at 21:21

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.