nodejs/node · error · GypError
Target %s has type %s but standalone_static_library flag is
Error message
Target %s has type %s but standalone_static_library flag is only valid for static_library type.
What it means
The 'standalone_static_library' flag is only meaningful for targets of type 'static_library'. ValidateTargetType raises GypError when the flag is truthy (non-zero) but target_type != 'static_library' (e.g. executable, shared_library, none).
Source
Thrown at tools/gyp/pylib/gyp/input.py:2699
"executable",
"loadable_module",
"static_library",
"shared_library",
"mac_kernel_extension",
"none",
"windows_driver",
)
target_type = target_dict.get("type", None)
if target_type not in VALID_TARGET_TYPES:
raise GypError(
"Target %s has an invalid target type '%s'. "
"Must be one of %s." % (target, target_type, "/".join(VALID_TARGET_TYPES))
)
if (
target_dict.get("standalone_static_library", 0)
and not target_type == "static_library"
):
raise GypError(
"Target %s has type %s but standalone_static_library flag is"
" only valid for static_library type." % (target, target_type)
)
def ValidateRulesInTarget(target, target_dict, extra_sources_for_rules):
"""Ensures that the rules sections in target_dict are valid and consistent,
and determines which sources they apply to.
Arguments:
target: string, name of target.
target_dict: dict, target spec containing "rules" and "sources" lists.
extra_sources_for_rules: a list of keys to scan for rule matches in
addition to 'sources'.
"""
# Dicts to map between values found in rules' 'rule_name' and 'extension'
# keys and the rule dicts themselves.View on GitHub (pinned to 1b2de5e052)
Solutions
- Remove 'standalone_static_library' from non-static_library targets.
- Or change the target's 'type' back to 'static_library' if standalone behavior is intended.
- Audit shared templates/generators that set the flag globally.
Example fix
// before: { 'target_name':'foo', 'type':'executable', 'standalone_static_library': 1 }
// after: { 'target_name':'foo', 'type':'executable' } Defensive patterns
Strategy: validation
Validate before calling
for t, spec in targets.items():
if spec.get('standalone_static_library') and spec.get('type') != 'static_library':
raise SystemExit('standalone_static_library only valid for static_library: %s' % t)
Type guard
def standalone_flag_ok(spec): return not spec.get('standalone_static_library') or spec.get('type') == 'static_library' Try / catch
try:
gyp.main(args)
except gyp.input.GypError as e:
if 'standalone_static_library' in str(e): print('Remove the flag or set type to static_library'); raise Prevention
- Set standalone_static_library only on static_library targets.
- Strip the flag when changing a target's type.
- Lint for orphaned flags during refactors.
When it happens
Trigger: target_dict.get('standalone_static_library') is truthy AND target_type is not exactly 'static_library'.
Common situations: Copy-pasting a static_library target and changing its type to executable/shared_library while leaving the flag; misunderstanding the flag as a general optimization; template that sets the flag unconditionally.
Related errors
- Missing 'target_name' field in target.
- Missing 'type' field in target %s
- Target %s has an invalid target type '%s'. Must be one of %
- Found wildcard in {dependency_key} of {target} referring to
- Dependency '%s' not found while trying to load target %s
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/656d64bf01d0c368.
Report an issue: GitHub.