nodejs/node · error · GypError
Could not find target %s
Error message
Could not find target %s
What it means
PruneUnwantedTargets is invoked when gyp is told to build only a subset of targets (e.g. via the --build/--depth root target list). For each requested target string it calls gyp.common.FindQualifiedTargets against the full flat target list; if nothing matches the (possibly qualified) name, gyp cannot proceed and raises GypError.
Source
Thrown at tools/gyp/pylib/gyp/input.py:2860
def TurnIntIntoStrInList(the_list):
"""Given list the_list, recursively converts all integers into strings."""
for index, item in enumerate(the_list):
if isinstance(item, int):
the_list[index] = str(item)
elif isinstance(item, dict):
TurnIntIntoStrInDict(item)
elif isinstance(item, list):
TurnIntIntoStrInList(item)
def PruneUnwantedTargets(targets, flat_list, dependency_nodes, root_targets, data):
"""Return only the targets that are deep dependencies of |root_targets|."""
qualified_root_targets = []
for target in root_targets:
target = target.strip()
qualified_targets = gyp.common.FindQualifiedTargets(target, flat_list)
if not qualified_targets:
raise GypError("Could not find target %s" % target)
qualified_root_targets.extend(qualified_targets)
wanted_targets = {}
for target in qualified_root_targets:
wanted_targets[target] = targets[target]
for dependency in dependency_nodes[target].DeepDependencies():
wanted_targets[dependency] = targets[dependency]
wanted_flat_list = [t for t in flat_list if t in wanted_targets]
# Prune unwanted targets from each build_file's data dict.
for build_file in data["target_build_files"]:
if "targets" not in data[build_file]:
continue
new_targets = []
for target in data[build_file]["targets"]:
qualified_name = gyp.common.QualifiedTarget(
build_file, target["target_name"], target["toolset"]View on GitHub (pinned to 1b2de5e052)
Solutions
- List available targets (gyp --dump-input or inspect the relevant .gyp files) and confirm the exact qualified name 'path/file.gyp:target'.
- Correct the spelling/path/case of the requested target to match exactly.
- If the target was removed or renamed, update the build invocation to the new name.
- Ensure the .gyp file containing the target is included in the build (depth/source arguments).
Example fix
// before $ gyp --depth=. build/all.gyp build/missing.gyp:ghost_target // after $ gyp --depth=. build/all.gyp build/real.gyp:real_target
Defensive patterns
Strategy: validation
Validate before calling
# Validate requested root targets against the known flat list before pruning.
known = set(flat_list)
for t in root_targets:
if not gyp.common.FindQualifiedTargets(t.strip(), flat_list):
raise ValueError(f'requested target not found: {t}') Type guard
def all_root_targets_resolvable(root_targets, flat_list) -> bool:
return all(
gyp.common.FindQualifiedTargets(t.strip(), flat_list)
for t in root_targets
) Prevention
- Quote target names exactly as defined (case-sensitive).
- When renaming/removing a target, update all build scripts and CI configs that reference it.
- Prefer fully-qualified 'path/file.gyp:target' forms to avoid ambiguity.
When it happens
Trigger: A target specifier passed to gyp as a root target does not match any entry in the flattened target list, after stripping and qualified-name resolution.
Common situations: Typing a target name that does not exist or was renamed; using a path qualifier (foo.gyp:bar) that points to a different file or target; referencing a target from a .gyp file that is not part of the build; case mismatch in the target name.
Related errors
- Duplicate target definitions for {target_name}
- Duplicate target name "%s" in directory "%s" used both in "%
- Unknown token id or value "${id}".
- --depfile requires --stamp and vice versa
- --depfile requires --stamp and vice versa
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/38df5942ff5631b0.
Report an issue: GitHub.