{"record":{"id":"656d64bf01d0c368","repo":"nodejs/node","slug":"target-s-has-type-s-but-standalone-static-librar","errorCode":null,"errorMessage":"Target %s has type %s but standalone_static_library flag is only valid for static_library type.","messagePattern":"Target (.+?) has type (.+?) but standalone_static_library flag is only valid for static_library type\\.","errorType":"exception","errorClass":"GypError","httpStatus":null,"severity":"error","filePath":"tools/gyp/pylib/gyp/input.py","lineNumber":2699,"sourceCode":"        \"executable\",\n        \"loadable_module\",\n        \"static_library\",\n        \"shared_library\",\n        \"mac_kernel_extension\",\n        \"none\",\n        \"windows_driver\",\n    )\n    target_type = target_dict.get(\"type\", None)\n    if target_type not in VALID_TARGET_TYPES:\n        raise GypError(\n            \"Target %s has an invalid target type '%s'.  \"\n            \"Must be one of %s.\" % (target, target_type, \"/\".join(VALID_TARGET_TYPES))\n        )\n    if (\n        target_dict.get(\"standalone_static_library\", 0)\n        and not target_type == \"static_library\"\n    ):\n        raise GypError(\n            \"Target %s has type %s but standalone_static_library flag is\"\n            \" only valid for static_library type.\" % (target, target_type)\n        )\n\n\ndef ValidateRulesInTarget(target, target_dict, extra_sources_for_rules):\n    \"\"\"Ensures that the rules sections in target_dict are valid and consistent,\n    and determines which sources they apply to.\n\n    Arguments:\n      target: string, name of target.\n      target_dict: dict, target spec containing \"rules\" and \"sources\" lists.\n      extra_sources_for_rules: a list of keys to scan for rule matches in\n          addition to 'sources'.\n    \"\"\"\n\n    # Dicts to map between values found in rules' 'rule_name' and 'extension'\n    # keys and the rule dicts themselves.","sourceCodeStart":2681,"sourceCodeEnd":2717,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/tools/gyp/pylib/gyp/input.py#L2681-L2717","documentation":"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).","triggerScenarios":"target_dict.get('standalone_static_library') is truthy AND target_type is not exactly 'static_library'.","commonSituations":"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.","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."],"exampleFix":"// before: { 'target_name':'foo', 'type':'executable', 'standalone_static_library': 1 }\n// after: { 'target_name':'foo', 'type':'executable' }","handlingStrategy":"validation","validationCode":"for t, spec in targets.items():\n    if spec.get('standalone_static_library') and spec.get('type') != 'static_library':\n        raise SystemExit('standalone_static_library only valid for static_library: %s' % t)\n","typeGuard":"def standalone_flag_ok(spec): return not spec.get('standalone_static_library') or spec.get('type') == 'static_library'","tryCatchPattern":"try:\n    gyp.main(args)\nexcept gyp.input.GypError as e:\n    if 'standalone_static_library' in str(e): print('Remove the flag or set type to static_library'); raise","preventionTips":["Set standalone_static_library only on static_library targets.","Strip the flag when changing a target's type.","Lint for orphaned flags during refactors."],"tags":["gyp","target-spec","validation","build-config"],"backgroundTag":null,"analyzedSha":"1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e","analyzedAt":"2026-08-13T00:53:24.642Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}