parcel-bundler/parcel · error · ThrowableDiagnostic

Could not find target with name

Error message

Could not find target with name "${target}"

What it means

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.

Solutions

  1. List the available targets in package.json and use one of those exact names.
  2. Check for typos in the target name (case-sensitive).
  3. If you intended to create a new target, add it to the targets section of package.json first.
  4. In a monorepo, ensure you're referencing a target defined in the correct package.json.

Example fix

// before — package.json targets
{
  "targets": {
    "main": { "distDir": "dist" }
  }
}
// CLI: parcel build --target moden src/index.html

// after — fix the typo
parcel build --target modern src/index.html
// or match exactly:
parcel build --target main src/index.html
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs');
function validateTargetNamesExist(pkgPath, requestedTargets) {
  const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
  const available = pkg.targets ? Object.keys(pkg.targets) : [];
  for (const name of requestedTargets) {
    if (!available.includes(name)) {
      throw new Error(`Target "${name}" not found. Available: ${available.join(', ') || '(none)'}`);
    }
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of parcel-bundler/parcel@59484858a1 (2026-08-13). Data as JSON: /api/errors/bd9a722ab7cc0aa3. Report an issue: GitHub.

Appendix: source

Thrown at packages/core/core/src/requests/TargetRequest.js:236

              origin: '@parcel/core',
            },
          });
        }

        // Only build the intersection of the exclusive target and option targets.
        if (exclusiveTarget != null) {
          optionTargets = optionTargets.filter(
            target => target === exclusiveTarget,
          );
        }

        // If an array of strings is passed, it's a filter on the resolved package
        // targets. Load them, and find the matching targets.
        targets = optionTargets
          .map(target => {
            // null means skipped.
            if (!packageTargets.has(target)) {
              throw new ThrowableDiagnostic({
                diagnostic: {
                  message: md`Could not find target with name "${target}"`,
                  origin: '@parcel/core',
                },
              });
            }
            return packageTargets.get(target);
          })
          .filter(Boolean);
      } else {
        // Otherwise, it's an object map of target descriptors (similar to those
        // in package.json). Adapt them to native targets.
        targets = Object.entries(optionTargets)
          .map(([name, _descriptor]) => {
            let {distDir, ...descriptor} = parseDescriptor(
              name,
              _descriptor,
              null,

View on GitHub (pinned to 59484858a1)