{"record":{"id":"3a39b07c31cceb65","repo":"nodejs/node","slug":"missing-type-field-in-target-s","errorCode":null,"errorMessage":"Missing 'type' field in target %s","messagePattern":"Missing 'type' field in target (.+?)","errorType":"exception","errorClass":"GypError","httpStatus":null,"severity":"error","filePath":"tools/gyp/pylib/gyp/input.py","lineNumber":1845,"sourceCode":"        \"\"\"\n        if dependencies is None:\n            # Using a list to get ordered output and a set to do fast \"is it\n            # already added\" checks.\n            dependencies = OrderedSet()\n\n        # Check for None, corresponding to the root node.\n        if self.ref is None:\n            return dependencies\n\n        # It's kind of sucky that |targets| has to be passed into this function,\n        # but that's presently the easiest way to access the target dicts so that\n        # this function can find target types.\n\n        if \"target_name\" not in targets[self.ref]:\n            raise GypError(\"Missing 'target_name' field in target.\")\n\n        if \"type\" not in targets[self.ref]:\n            raise GypError(\n                \"Missing 'type' field in target %s\" % targets[self.ref][\"target_name\"]\n            )\n\n        target_type = targets[self.ref][\"type\"]\n\n        is_linkable = target_type in linkable_types\n\n        if initial and not is_linkable:\n            # If this is the first target being examined and it's not linkable,\n            # return an empty list of link dependencies, because the link\n            # dependencies are intended to apply to the target itself (initial is\n            # True) and this target won't be linked.\n            return dependencies\n\n        # Don't traverse 'none' targets if explicitly excluded.\n        if target_type == \"none\" and not targets[self.ref].get(\n            \"dependencies_traverse\", True\n        ):","sourceCodeStart":1827,"sourceCodeEnd":1863,"githubUrl":"https://github.com/nodejs/node/blob/1b2de5e052fc0fb95fd7fb6846dcec4ade598e9e/tools/gyp/pylib/gyp/input.py#L1827-L1863","documentation":"After confirming a target has 'target_name', the dependency-walk guard at input.py:1845 requires a 'type' field to classify the target (linkable vs not, via linkable_types). Without 'type' the graph cannot decide link behavior, so gyp raises GypError naming the target.","triggerScenarios":"targets[self.ref] contains 'target_name' but is missing the 'type' key, hit while computing link dependencies for a node.","commonSituations":"Target dict with target_name but a forgotten/typo'd type field; conditional that strips type; include file that partially overrides a target; migration from an older gyp that defaulted type.","solutions":["Add a 'type' field set to one of the VALID_TARGET_TYPES (executable, static_library, shared_library, loadable_module, mac_kernel_extension, none, windows_driver).","Check for stray conditionals or includes that delete 'type'.","Validate the .gyp file with gyp --check."],"exampleFix":"// before\n{ 'target_name': 'foo', 'sources': ['a.cc'] }\n\n// after\n{ 'target_name': 'foo', 'type': 'static_library', 'sources': ['a.cc'] }","handlingStrategy":"validation","validationCode":"VALID = {'executable','static_library','shared_library','loadable_module','mac_kernel_extension','none','windows_driver'}\nfor t in spec.get('targets', []):\n    assert t.get('type') in VALID, 'bad/missing type in %s' % t.get('target_name')\n","typeGuard":"def valid_type(t): return t.get('type') in {'executable','static_library','shared_library','loadable_module','mac_kernel_extension','none','windows_driver'}","tryCatchPattern":"try:\n    gyp.main(args)\nexcept gyp.input.GypError as e:\n    if \"Missing 'type' field\" in str(e): print('Add a valid type field'); raise","preventionTips":["Always pair target_name with type.","Keep a shared template/macro that emits both fields.","Lint for missing type 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"}