{"record":{"id":"cfd3624528b85f99","repo":"nodejs/node","slug":"target-s-has-an-invalid-target-type-s-must-b","errorCode":null,"errorMessage":"Target %s has an invalid target type '%s'.  Must be one of %s.","messagePattern":"Target (.+?) has an invalid target type '(.+?)'\\.  Must be one of (.+?)\\.","errorType":"exception","errorClass":"GypError","httpStatus":null,"severity":"error","filePath":"tools/gyp/pylib/gyp/input.py","lineNumber":2691,"sourceCode":"\n    Arguments:\n      target: string, name of target.\n      target_dict: dict, target spec.\n\n    Raises an exception on error.\n    \"\"\"\n    VALID_TARGET_TYPES = (\n        \"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:","sourceCodeStart":2673,"sourceCodeEnd":2709,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/tools/gyp/pylib/gyp/input.py#L2673-L2709","documentation":"ValidateTargetType restricts 'type' to a fixed set VALID_TARGET_TYPES: executable, loadable_module, static_library, shared_library, mac_kernel_extension, none, windows_driver. A type outside this set (or missing, since .get returns None) raises GypError listing the allowed values joined by '/'.","triggerScenarios":"target_dict['type'] (via .get defaulting None) is not one of the seven valid strings. Reached during target validation in the load pipeline.","commonSituations":"Typo like 'static_libary' or 'shared_lib'; using a non-portable type; omitting 'type' entirely; using a generator-specific type the core does not recognize; stale type from an old gyp version.","solutions":["Set 'type' to one of: executable, static_library, shared_library, loadable_module, mac_kernel_extension, none, windows_driver.","Fix typos in the type string.","If the type was omitted, add it explicitly.","Confirm the type is supported by the generator in use."],"exampleFix":"// before: { 'target_name':'foo', 'type':'static_lib' }\n// after: { 'target_name':'foo', 'type':'static_library' }","handlingStrategy":"validation","validationCode":"VALID = ('executable','loadable_module','static_library','shared_library','mac_kernel_extension','none','windows_driver')\nfor t, spec in targets.items():\n    assert spec.get('type') in VALID, 'invalid type for %s' % t\n","typeGuard":"def valid_target_type(spec): return spec.get('type') in ('executable','loadable_module','static_library','shared_library','mac_kernel_extension','none','windows_driver')","tryCatchPattern":"try:\n    gyp.main(args)\nexcept gyp.input.GypError as e:\n    if 'invalid target type' in str(e): print('Set type to one of the VALID_TARGET_TYPES'); raise","preventionTips":["Always set a valid type string.","Reuse a target template with the correct type.","Lint types in pre-commit."],"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"}