{"id":"c1ac3479354b52db","repo":"webpack/webpack","slug":"library-type-module-is-only-allowed-when-experi","errorCode":null,"errorMessage":"library type \"module\" is only allowed when 'experiments.outputModule' is enabled","messagePattern":"library type \"module\" is only allowed when 'experiments\\.outputModule' is enabled","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/WebpackOptionsApply.js","lineNumber":503,"sourceCode":"\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tnew JavascriptModulesPlugin().apply(compiler);\n\n\t\tnew JsonModulesPlugin().apply(compiler);\n\t\tnew AssetModulesPlugin({\n\t\t\tsideEffectFree: options.experiments.futureDefaults\n\t\t}).apply(compiler);\n\n\t\tif (!options.experiments.outputModule) {\n\t\t\tif (options.output.module) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"'output.module: true' is only allowed when 'experiments.outputModule' is enabled\"\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (options.output.enabledLibraryTypes.includes(\"module\")) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"library type \\\"module\\\" is only allowed when 'experiments.outputModule' is enabled\"\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (options.output.enabledLibraryTypes.includes(\"modern-module\")) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"library type \\\"modern-module\\\" is only allowed when 'experiments.outputModule' is enabled\"\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (\n\t\t\t\toptions.externalsType === \"module\" ||\n\t\t\t\toptions.externalsType === \"module-import\"\n\t\t\t) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"'externalsType: \\\"module\\\"' is only allowed when 'experiments.outputModule' is enabled\"\n\t\t\t\t);\n\t\t\t}\n\t\t}\n","sourceCodeStart":485,"sourceCodeEnd":521,"githubUrl":"https://github.com/webpack/webpack/blob/318421ea8ac81371f5171236a6efb63675576528/lib/WebpackOptionsApply.js#L485-L521","documentation":"Error \"library type \"module\" is only allowed when 'experiments.outputModule' is enabled\" thrown in webpack/webpack.","triggerScenarios":"Thrown at lib/WebpackOptionsApply.js:503 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Enable experiments.outputModule: true in the webpack configuration when using output.library.type: 'module'."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"318421ea8ac81371f5171236a6efb63675576528","analyzedAt":"2026-08-03T19:39:56.731Z","schemaVersion":2}