{"record":{"id":"bd9a722ab7cc0aa3","repo":"parcel-bundler/parcel","slug":"could-not-find-target-with-name-target","errorCode":null,"errorMessage":"Could not find target with name \"${target}\"","messagePattern":"Could not find target with name \"(.+?)\"","errorType":"exception","errorClass":"ThrowableDiagnostic","httpStatus":null,"severity":"error","filePath":"packages/core/core/src/requests/TargetRequest.js","lineNumber":236,"sourceCode":"              origin: '@parcel/core',\n            },\n          });\n        }\n\n        // Only build the intersection of the exclusive target and option targets.\n        if (exclusiveTarget != null) {\n          optionTargets = optionTargets.filter(\n            target => target === exclusiveTarget,\n          );\n        }\n\n        // If an array of strings is passed, it's a filter on the resolved package\n        // targets. Load them, and find the matching targets.\n        targets = optionTargets\n          .map(target => {\n            // null means skipped.\n            if (!packageTargets.has(target)) {\n              throw new ThrowableDiagnostic({\n                diagnostic: {\n                  message: md`Could not find target with name \"${target}\"`,\n                  origin: '@parcel/core',\n                },\n              });\n            }\n            return packageTargets.get(target);\n          })\n          .filter(Boolean);\n      } else {\n        // Otherwise, it's an object map of target descriptors (similar to those\n        // in package.json). Adapt them to native targets.\n        targets = Object.entries(optionTargets)\n          .map(([name, _descriptor]) => {\n            let {distDir, ...descriptor} = parseDescriptor(\n              name,\n              _descriptor,\n              null,","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/core/core/src/requests/TargetRequest.js#L218-L254","documentation":"Thrown by TargetRequest.resolve() when a target name in the optionTargets array does not exist in the package's resolved targets map (packageTargets). Each name is checked against packageTargets.has(target); a miss means the name doesn't correspond to any target defined in package.json.","triggerScenarios":"Inside optionTargets.map(target => ...), when packageTargets.has(target) is false. packageTargets comes from resolvePackageTargets(rootDir) which reads the targets section of package.json. The requested name has no matching entry.","commonSituations":"Passing --target myapp when package.json defines targets named 'main', 'modern', etc.; typo in the target name; target was renamed in package.json but the CLI/option still references the old name; passing a target name from a different package in a monorepo.","solutions":["List the available targets in package.json and use one of those exact names.","Check for typos in the target name (case-sensitive).","If you intended to create a new target, add it to the targets section of package.json first.","In a monorepo, ensure you're referencing a target defined in the correct package.json."],"exampleFix":"// before — package.json targets\n{\n  \"targets\": {\n    \"main\": { \"distDir\": \"dist\" }\n  }\n}\n// CLI: parcel build --target moden src/index.html\n\n// after — fix the typo\nparcel build --target modern src/index.html\n// or match exactly:\nparcel build --target main src/index.html","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nfunction validateTargetNamesExist(pkgPath, requestedTargets) {\n  const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));\n  const available = pkg.targets ? Object.keys(pkg.targets) : [];\n  for (const name of requestedTargets) {\n    if (!available.includes(name)) {\n      throw new Error(`Target \"${name}\" not found. Available: ${available.join(', ') || '(none)'}`);\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cross-reference --target names against the targets section in package.json.","Keep target names stable — avoid renaming them without updating build scripts.","List available targets in CI logs to catch mismatches early."],"tags":["targets","config","package-json","validation"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}