parcel-bundler/parcel · error · Error
No dynamic require possible: ${workerPath}
Error message
No dynamic require possible: ${workerPath} What it means
Thrown by WorkerFarm when process.browser is true (running in a browser bundle) and options.workerPath is not the one allowed browser entry '@parcel/core/src/worker.js'. In a browser there is no dynamic require, so only the pre-bundled coreWorker reference is permitted; any other path is rejected.
Source
Thrown at packages/core/workers/src/WorkerFarm.js:111
farmOptions.shouldTrace ? 1 : DEFAULT_MAX_CONCURRENT_CALLS,
),
forcedKillTime: 500,
warmWorkers: false,
useLocalWorker: true, // TODO: setting this to false makes some tests fail, figure out why
backend: detectBackend(),
...farmOptions,
};
if (!this.options.workerPath) {
throw new Error('Please provide a worker path!');
}
// $FlowFixMe
if (process.browser) {
if (this.options.workerPath === '@parcel/core/src/worker.js') {
this.localWorker = coreWorker;
} else {
throw new Error(
'No dynamic require possible: ' + this.options.workerPath,
);
}
} else {
// $FlowFixMe this must be dynamic
this.localWorker = require(this.options.workerPath);
}
this.localWorkerInit =
this.localWorker.childInit != null ? this.localWorker.childInit() : null;
this.run = this.createHandle('run');
// Worker thread stdout is by default piped into the process stdout, if there are enough worker
// threads to exceed the default listener limit, then anything else piping into stdout will trigger
// the `MaxListenersExceededWarning`, so we should ensure the max listeners is at least equal to the
// number of workers + 1 for the main thread.
//View on GitHub (pinned to 59484858a1)
Solutions
- In browser builds, leave workerPath unset or set it to '@parcel/core/src/worker.js' so the pre-bundled coreWorker is used.
- Avoid bundling @parcel/workers into browser code unless you specifically support the web worker backend.
- Use the 'web' worker backend and ensure the bundler exposes coreWorker via the expected module id.
Example fix
// before (browser bundle)
new WorkerFarm({ workerPath: './myWorker.js' });
// after
new WorkerFarm({ workerPath: '@parcel/core/src/worker.js' }); Defensive patterns
Strategy: validation
Validate before calling
if (process.browser && options.workerPath !== '@parcel/core/src/worker.js') {
throw new Error('In browser builds only the bundled core worker path is allowed.');
} Prevention
- In browser bundles, default workerPath to '@parcel/core/src/worker.js'.
- Avoid bundling @parcel/workers into the browser unless you support the web backend.
- Mark Node-only worker modules as external/excluded in the browser bundler config.
When it happens
Trigger: Bundling @parcel/workers for the browser (e.g. with webpack/rollup) and setting workerPath to a custom module; running Parcel's worker code in a browser context that is not the bundled core worker.
Common situations: Reusing @parcel/workers in a browser/web worker toolchain; accidentally including Parcel's worker code in a web bundle via a misconfigured bundler; web-based Parcel playgrounds.
Related errors
- No dynamic require possible: ${location}
- No dynamic require possible: ${module}
- Please provide a worker path!
- IDBCache is only supported in the browser
- Supplied WorkerFarm is ending
AI-assisted analysis of parcel-bundler/parcel@59484858a1 (2026-08-13).
Data as JSON: /api/errors/94561f404071169d.
Report an issue: GitHub.