What directory should a new module get installed into when using composer? The reason I ask is because I have my site setup at home on wamp and then the live site is hosted. When I install the metatag, token and token or modules on my home computer, they intall in the modules/contrib folder. When I install it into the live site, they get installed into the modules folder. Which is the correct one and why is this discrepency happening?

Comments

Jaypan’s picture

the /modules/contrib folder is correct, although they will also be picked up if they are in the /modules folder. But, it's not normal that they would not be installed to the same folder - are you using different composer.json files for the environment? If they are a copy of each other, they will install to the same directory.

holljac’s picture

Could I just copy my local composer.json to the hosted one?

holljac’s picture

Installer path is listed as            

"modules/contrib/{$name}": [
                "type:drupal-module"
            ],

in both local and remote.

fkelly12054@gmail.com’s picture

In composer.json there should be an installer path section that looks like this:

"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/profiles/custom/{$name}": [
                "type:drupal-custom-profile"
            ],
            "web/themes/custom/{$name}": [
                "type:drupal-custom-theme"
            ]
        },

You might want to check (compare) the two composer.jsons (hosted and local) and make sure the contrib modules are in the contrib path.