nodejs/node · error · GypError

%s not allowed in the %s configuration, found in target %s

Error message

%s not allowed in the %s configuration, found in target %s

What it means

After splitting target-level keys out of configurations, gyp validates that no key listed in invalid_configuration_keys appears inside any configuration dict. invalid_configuration_keys includes actions, all_dependent_settings, configurations, dependencies, direct_dependent_settings, libraries, link_settings, sources, standalone_static_library, target_name, type — these belong at the TARGET level, not inside a configuration.

Source

Thrown at tools/gyp/pylib/gyp/input.py:2485

    # Now that all of the target's configurations have been built, go through
    # the target dict's keys and remove everything that's been moved into a
    # "configurations" section.
    delete_keys = []
    for key in target_dict:
        key_ext = key[-1:]
        key_base = key[:-1] if key_ext in key_suffixes else key
        if key_base not in non_configuration_keys:
            delete_keys.append(key)
    for key in delete_keys:
        del target_dict[key]

    # Check the configurations to see if they contain invalid keys.
    for configuration in target_dict["configurations"]:
        configuration_dict = target_dict["configurations"][configuration]
        for key in configuration_dict:
            if key in invalid_configuration_keys:
                raise GypError(
                    "%s not allowed in the %s configuration, found in "
                    "target %s" % (key, configuration, target)
                )


def ProcessListFiltersInDict(name, the_dict):
    """Process regular expression and exclusion-based filters on lists.

    An exclusion list is in a dict key named with a trailing "!", like
    "sources!".  Every item in such a list is removed from the associated
    main list, which in this example, would be "sources".  Removed items are
    placed into a "sources_excluded" list in the dict.

    Regular expression (regex) filters are contained in dict keys named with a
    trailing "/", such as "sources/" to operate on the "sources" list.  Regex
    filters in a dict take the form:
      'sources/': [ ['exclude', '_(linux|mac|win)\\.cc$'],
                    ['include', '_mac\\.cc$'] ],

View on GitHub (pinned to 1b2de5e052)

Solutions

  1. Move the offending key (sources, dependencies, type, etc.) out of the configuration dict to the target level.
  2. Keep only compiler/linker settings (cflags, defines, include_dirs, ldflags, etc.) inside configurations.
  3. Fix indentation so configuration keys are siblings, not children, of target keys.
  4. Run gyp --check to catch placement errors early.

Example fix

// before
{ 'target_name':'foo', 'type':'static_library',
  'configurations': { 'Debug': { 'sources': ['a.cc'], 'defines':['DEBUG'] } } }
// after
{ 'target_name':'foo', 'type':'static_library', 'sources': ['a.cc'],
  'configurations': { 'Debug': { 'defines':['DEBUG'] } } }
Defensive patterns

Strategy: validation

Validate before calling

INVALID = {'actions','all_dependent_settings','configurations','dependencies','direct_dependent_settings','libraries','link_settings','sources','standalone_static_library','target_name','type'}
for cfg, cd in target_dict.get('configurations', {}).items():
    bad = INVALID & set(cd)
    assert not bad, 'invalid keys in config %s: %r' % (cfg, bad)

Try / catch

try:
    gyp.main(args)
except gyp.input.GypError as e:
    if 'not allowed in the' in str(e) and 'configuration' in str(e): print('Move target-level keys out of configurations'); raise

Prevention

When it happens

Trigger: A 'configurations' entry dict contains one of the forbidden keys (e.g. 'sources', 'dependencies', 'type', 'target_name'). The loop at input.py:~2485 raises GypError naming the key, the configuration name, and the target.

Common situations: Indentation mistake that nested target-level keys under a configuration; copy-pasting a target block into a configuration; misunderstanding that sources/dependencies are target-scoped; migrating from a generator that was lenient.

Related errors


AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13). Data as JSON: /api/errors/8b1043062fe7cca3. Report an issue: GitHub.