{"record":{"id":"7d96029eb498746e","repo":"angular/angular-cli","slug":"compilation-output-path-cannot-be-empty","errorCode":null,"errorMessage":"Compilation output path cannot be empty.","messagePattern":"Compilation output path cannot be empty\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/build_angular/src/tools/webpack/plugins/service-worker-plugin.ts","lineNumber":38,"sourceCode":"  constructor(private readonly options: ServiceWorkerPluginOptions) {}\n\n  apply(compiler: Compiler) {\n    compiler.hooks.done.tapPromise('angular-service-worker', async (stats) => {\n      if (stats.hasErrors()) {\n        // Don't generate a service worker if the compilation has errors.\n        // When there are errors some files will not be emitted which would cause other errors down the line such as readdir failures.\n        return;\n      }\n\n      const { projectRoot, root, baseHref = '', ngswConfigPath } = this.options;\n      const { compilation } = stats;\n      // We use the output path from the compilation instead of build options since during\n      // localization the output path is modified to a temp directory.\n      // See: https://github.com/angular/angular-cli/blob/7e64b1537d54fadb650559214fbb12707324cd75/packages/angular_devkit/build_angular/src/utils/i18n-options.ts#L251-L252\n      const outputPath = compilation.outputOptions.path;\n\n      if (!outputPath) {\n        throw new Error('Compilation output path cannot be empty.');\n      }\n\n      try {\n        await augmentAppWithServiceWorker(\n          projectRoot,\n          root,\n          outputPath,\n          baseHref,\n          ngswConfigPath,\n          // eslint-disable-next-line @typescript-eslint/no-explicit-any\n          (compiler.inputFileSystem as any).promises,\n          // eslint-disable-next-line @typescript-eslint/no-explicit-any\n          (compiler.outputFileSystem as any).promises,\n        );\n      } catch (error) {\n        compilation.errors.push(\n          new compilation.compiler.webpack.WebpackError(\n            `Failed to generate service worker - ${error instanceof Error ? error.message : error}`,","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/build_angular/src/tools/webpack/plugins/service-worker-plugin.ts#L20-L56","documentation":"The ServiceWorkerPlugin's apply() augments the built app with a service worker after compilation. It reads the output path from compilation.outputOptions.path (not build options) because localization may redirect output to a temp directory. If that path is empty/undefined, the plugin cannot locate the output to augment, so it throws.","triggerScenarios":"Running a build with service worker enabled (ngswConfigPath set) while the webpack compilation's outputOptions.path is empty — e.g. an misconfigured output path, dev-server in-memory output without a path, or a custom webpack config overriding output.","commonSituations":"Custom webpack configs that clear/override `output.path`; running via dev-server with service worker enabled where output is memory-only; programmatic use of the builder without a valid output path; localization builds where the temp output path setup failed.","solutions":["Ensure `outputPath` in your build options is set and non-empty.","Remove any custom webpack configuration that overrides or empties `output.path`.","Disable the service worker (`serviceWorker: false` or remove ngswConfigPath) if building in an environment without a real output path (e.g. dev-server).","Upgrade Angular CLI; later versions handle dev-server/service-worker combinations differently."],"exampleFix":"// before (angular.json)\n\"options\": { \"serviceWorker\": true, \"ngswConfigPath\": \"ngsw-config.json\" }\n// after (when using dev-server / no outputPath)\n\"configurations\": { \"development\": { \"serviceWorker\": false } }","handlingStrategy":"validation","validationCode":"const outputPath = compilation.outputOptions.path;\nif (!outputPath) throw new Error('Cannot enable service worker: compilation output path is empty.');","typeGuard":"function hasOutputPath(o: webpack.Compilation['outputOptions']): o is typeof o & { path: string } {\n  return typeof o.path === 'string' && o.path.length > 0;\n}","tryCatchPattern":"try {\n  await runBuild();\n} catch (err) {\n  if (err instanceof Error && err.message === 'Compilation output path cannot be empty.') {\n    logger.error('Service worker enabled but no output path set; check outputPath/output.path in your config.');\n  } else throw err;\n}","preventionTips":["Always set outputPath in angular.json when serviceWorker is enabled.","Never override webpack output.path to empty in custom webpack configs.","Disable serviceWorker in dev-server/development configurations.","Keep the CLI version matched with your webpack version."],"tags":["webpack","service-worker","configuration"],"backgroundTag":"missing-output-path","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}