Problem with field storage for custom content type modules I have multiple modules for custom content types (like "node_type_food" and "node_type_wine"), based on "node_type_example" in the drupal examples module. 

I can install a content type like "node_type_food" without any problems but  installing a second content type like "node_type_wine" with a common field (food &amp; wine both have a field "field_text") results in this error:


  Unable to install Content type wine, field.storage.node.field_text
  already exists in active configuration.


Without the field.storage.node.field_text.yml in config/install I can't install a content type when no other content type provides the field storage..


  Unable to install Node type wine, field.field.node.wine.field_text has
  unmet dependencies.


Edit: Problem also descibed in comment on Install a module that creates a content type with fileds via YAML
The Drupal's config management system which are you using to install configuration isn't really built for this. There are several ways to go about this. The main issue is that the config management system automatically create dependencies and such for you, which is a bit troublesome to manage.

Drupal doesn't have a concept of a shared field, it simple has a field store and field instance, but this isn't owned by a module.

So for solutions, there are some ways to go about this.


Let one module own the field storages you want to want to share and let modules that share fields depend on the module. Note the field can be deleted eventhough it's in a modules install folder, as it's just configuration, unless you lock it. A variation of this would be to combine the modules, into a single module, so all config is install at the same time.
Don't use shared fields - if the modules are independent, it makes sense that they shouldn't share configuration.
Use code to install fields. This is similar to how you define fields for entities, only you need to use FieldConfig and FieldStorageConfig. Drupal have many test cases that does this, which you can use as a guide. Some example code looks like this:

$this-&gt;fieldStorage = FieldStorageConfig::loadByName('entity_test', $field_name);
if (!$this-&gt;fieldStorage) {
  $this-&gt;fieldStorage = FieldStorageConfig::create(array(
    'field_name' =&gt; $field_name,
    'entity_type' =&gt; 'entity_test',
    'type' =&gt; 'link',
  ));
  $this-&gt;fieldStorage-&gt;save();
}

$this-&gt;field = FieldConfig::create([
  'field_storage' =&gt; $this-&gt;fieldStorage,
  'bundle' =&gt; 'entity_test',
  'settings' =&gt; array(
    'title' =&gt; DRUPAL_DISABLED,
    'link_type' =&gt; LinkItemInterface::LINK_GENERIC,
  ),
]);
$this-&gt;field-&gt;save();