webpack/webpack · error · Error
library type "module" is only allowed when 'experiments.outp
Error message
library type "module" is only allowed when 'experiments.outputModule' is enabled
What it means
Error "library type "module" is only allowed when 'experiments.outputModule' is enabled" thrown in webpack/webpack.
Source
Thrown at lib/WebpackOptionsApply.js:503
}
}
}
new JavascriptModulesPlugin().apply(compiler);
new JsonModulesPlugin().apply(compiler);
new AssetModulesPlugin({
sideEffectFree: options.experiments.futureDefaults
}).apply(compiler);
if (!options.experiments.outputModule) {
if (options.output.module) {
throw new Error(
"'output.module: true' is only allowed when 'experiments.outputModule' is enabled"
);
}
if (options.output.enabledLibraryTypes.includes("module")) {
throw new Error(
"library type \"module\" is only allowed when 'experiments.outputModule' is enabled"
);
}
if (options.output.enabledLibraryTypes.includes("modern-module")) {
throw new Error(
"library type \"modern-module\" is only allowed when 'experiments.outputModule' is enabled"
);
}
if (
options.externalsType === "module" ||
options.externalsType === "module-import"
) {
throw new Error(
"'externalsType: \"module\"' is only allowed when 'experiments.outputModule' is enabled"
);
}
}
View on GitHub (pinned to 318421ea8a)
Solutions
- Enable experiments.outputModule: true in the webpack configuration when using output.library.type: 'module'.
When it happens
Trigger: Thrown at lib/WebpackOptionsApply.js:503 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of webpack/webpack@318421ea8a (2026-08-03).
Data as JSON: /data/errors/c1ac3479354b52db.json.
Report an issue: GitHub.