parcel-bundler/parcel · error · Error

No dynamic require possible: ${location}

Error message

No dynamic require possible: ${location}

What it means

Thrown inside WorkerFarm's call dispatcher when process.browser is true and an incoming worker request references a module location other than '@parcel/workers/src/bus.js'. Because the browser cannot perform dynamic require(), only the bundled bus module is reachable; any other requested location is rejected.

Source

Thrown at packages/core/workers/src/WorkerFarm.js:363

  }

  async processRequest(
    data: {|
      location: FilePath,
    |} & $Shape<WorkerRequest>,
    worker?: Worker,
  ): Promise<?string> {
    let {method, args, location, awaitResponse, idx, handle: handleId} = data;
    let mod;
    if (handleId != null) {
      mod = nullthrows(this.handles.get(handleId)?.fn);
    } else if (location) {
      // $FlowFixMe
      if (process.browser) {
        if (location === '@parcel/workers/src/bus.js') {
          mod = (bus: any);
        } else {
          throw new Error('No dynamic require possible: ' + location);
        }
      } else {
        // $FlowFixMe this must be dynamic
        mod = require(location);
      }
    } else {
      throw new Error('Unknown request');
    }

    const responseFromContent = (content: any): WorkerDataResponse => ({
      idx,
      type: 'response',
      contentType: 'data',
      content,
    });

    const errorResponseFromError = (e: Error): WorkerErrorResponse => ({
      idx,

View on GitHub (pinned to 59484858a1)

Solutions

  1. Ensure plugins used in browser builds only reference modules bundled for the browser.
  2. Prefer handleId-based calls (registered handles) so no dynamic require is needed.
  3. Bundle the required module under '@parcel/workers/src/bus.js' alias, or avoid the worker dispatch path in the browser.
  4. Run the build in Node where dynamic require is allowed.

Example fix

// before — browser dispatch hits a Node-only location
call({ location: '@parcel/core/src/worker.js', ... })

// after — use a registered handle
call({ handle: registeredHandleId, ... })
Defensive patterns

Strategy: validation

Validate before calling

if (process.browser && location && location !== '@parcel/workers/src/bus.js') {
  throw new Error(`Cannot require '${location}' in a browser worker; use a registered handle.`);
}

Prevention

When it happens

Trigger: A worker call (via createHandle/run) is dispatched in a browser bundle where data.location points to a module that is neither the bundled bus nor reachable through a handleId. Happens when a Parcel plugin requests a worker module not bundled for the browser.

Common situations: Running Parcel's plugin pipeline in a browser build; a plugin that registers a worker-side request pointing to a Node-only module; misconfigured web worker backend.

Related errors


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