<p>Craft Plugins require that a <code>"type":"craft-plugin"</code> property is defined in each <code>composer.json</code> file. Composer refers to this to help manage and install the plugin. Craft Modules do not currently have this support. </p>

<p>You can see all package types that Composer Installer supports <a href="https://github.com/composer/installers#current-supported-package-types" rel="noreferrer">here</a>. There is still a way to achieve what you're trying to do though...</p>

<p><a href="https://github.com/oomphinc/composer-installers-extender" rel="noreferrer">Composer Installers Extender</a> allows you to create your own custom package type. So we could create <code>craft-module</code> ourselves. Just make sure your module has this <code>"type":"craft-module"</code> in it's <code>composer.json</code></p>

<p>Now we can define some <code>extra</code> settings that tell Composer to put the modules into the modules directory. Incorporate the following into your projects <code>composer.json</code> file:</p>

<pre><code>"require": {
  "oomphinc/composer-installers-extender": "^1.1",
  "vendorname/modulename": "dev-master"
},
"autoload": {
  "psr-4": {
    "modules\\": "modules/",
    "modules\\modulename\\": "modules/modulename/module/"
  }
},
"extra": {
  "installer-types": ["craft-module"],
  "installer-paths": {
    "modules/{$name}": ["type:craft-module"]
  }
},
</code></pre>

<p><em>Note: Make sure your module no longer exists in your vendor directory as you may be hit with some potential conflict warnings.</em></p>

CC BY-SA 4.0
2018-06-22T08:48:05.867Z
2018-06-22T09:08:48.410Z
2018-06-22T09:08:48.410Z
Mark Notton
<p>Installing a Craft 3 plugin via Composer is pretty simple. You require the package, update Composer, and install it via the CMS. </p>

<p>My circumstances require that our company use a private Module on all projects. But installing the package via Composer always puts the Module into the default <code>vendor</code> directory. </p>

<p>So how can I install a module into the modules folder?</p>

<craft3><composer><modules>
How can I install modules with Composer?
# How can I install modules with Composer?

(Asked by: username_0 on 2018-06-22)

Installing a Craft 3 plugin via Composer is pretty simple. You require the package, update Composer, and install it via the CMS.

My circumstances require that our company use a private Module on all projects. But installing the package via Composer always puts the Module into the default `vendor` directory.

So how can I install a module into the modules folder?

**Tags:** craft3, composer, modules


---

## 1 answers

### Answer by username_0 on 2018-06-22. Score: 6 | Accepted answer

Craft Plugins require that a "type":"craft-plugin" property is defined in each composer.json file. Composer refers to this to help manage and install the plugin. Craft Modules do not currently have this support. 
You can see all package types that Composer Installer supports here. There is still a way to achieve what you're trying to do though...
Composer Installers Extender allows you to create your own custom package type. So we could create craft-module ourselves. Just make sure your module has this "type":"craft-module" in it's composer.json
Now we can define some extra settings that tell Composer to put the modules into the modules directory. Incorporate the following into your projects composer.json file:
"require": {
  "oomphinc/composer-installers-extender": "^1.1",
  "vendorname/modulename": "dev-master"
},
"autoload": {
  "psr-4": {
    "modules\\": "modules/",
    "modules\\modulename\\": "modules/modulename/module/"
  }
},
"extra": {
  "installer-types": ["craft-module"],
  "installer-paths": {
    "modules/{$name}": ["type:craft-module"]
  }
},

Note: Make sure your module no longer exists in your vendor directory as you may be hit with some potential conflict warnings.


---

