parcel-bundler/parcel · error · Error

Unknown environment feature: ${feature}

Error message

Unknown environment feature: ${feature}

What it means

`Environment.supports(feature)` looks up the feature in a static `supportData` table keyed by known `EnvironmentFeature` values (`esmodules`, `dynamic-import`, `worker-module`, `service-worker-module`, `import-meta-url`, `import-meta-resolve`, `arrow-functions`, `global-this`). If the key is absent, the feature name is unknown and the call is a programming error rather than a feature-gating question.

Source

Thrown at packages/core/core/src/public/Environment.js:313

      }

      let minBrowsers = getExcludedBrowsers(minVersions);
      let withoutMinBrowsers = browserslist([...browsers, ...minBrowsers]);
      return matchedBrowsers.length === withoutMinBrowsers.length;
    } else if (this.isNode() && this.engines.node != null) {
      return (
        minVersions.node != null &&
        !semver.intersects(`< ${minVersions.node}`, this.engines.node)
      );
    }

    return defaultValue;
  }

  supports(feature: EnvironmentFeature, defaultValue?: boolean): boolean {
    let engines = supportData[feature];
    if (!engines) {
      throw new Error('Unknown environment feature: ' + feature);
    }

    return this.matchesEngines(engines, defaultValue);
  }
}

function getExcludedBrowsers(minVersions: VersionMap) {
  let browsers = [];
  for (let browser of ALL_BROWSERS) {
    let version = minVersions[browser];
    if (version) {
      browsers.push(`not ${browser} < ${version}`);
    } else {
      browsers.push(`not ${browser} > 0`);
    }
  }

  return browsers;

View on GitHub (pinned to 59484858a1)

Solutions

  1. Use one of the documented EnvironmentFeature string literals exactly.
  2. Upgrade Parcel if you need a feature that exists in a newer version.
  3. If unsure, enumerate `Object.keys(supportData)`-equivalent constants instead of hardcoding strings.

Example fix

// before
if (env.supports('es-module')) { ... } // typo

// after
if (env.supports('esmodules')) { ... }
Defensive patterns

Strategy: type-guard

Validate before calling

// Restrict calls to the known feature set.
const KNOWN = new Set([
  'esmodules','dynamic-import','worker-module','service-worker-module',
  'import-meta-url','import-meta-resolve','arrow-functions','global-this',
]);
if (!KNOWN.has(feature)) throw new Error(`unknown feature: ${feature}`);
const ok = env.supports(feature);

Type guard

function isKnownFeature(f: string): boolean {
  return new Set([
    'esmodules','dynamic-import','worker-module','service-worker-module',
    'import-meta-url','import-meta-resolve','arrow-functions','global-this',
  ]).has(f);
}

Prevention

When it happens

Trigger: Calling `env.supports('some-feature')` with a string not in the EnvironmentFeature union (typo, deprecated, or future feature).

Common situations: Typos in feature names; relying on a feature added in a newer Parcel while running an older version; passing a user-defined string.

Related errors


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