{"record":{"id":"17252556efaf469b","repo":"angular/angular-cli","slug":"could-not-find-server-output-directory-outputpa","errorCode":null,"errorMessage":"Could not find server output directory: ${outputPath}.","messagePattern":"Could not find server output directory: (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/build_angular/src/builders/app-shell/index.ts","lineNumber":148,"sourceCode":"\n  return browserResult;\n}\n\nasync function _getServerModuleBundlePath(\n  options: BuildWebpackAppShellSchema,\n  context: BuilderContext,\n  serverResult: ServerBuilderOutput,\n  browserLocaleDirectory: string,\n) {\n  if (options.appModuleBundle) {\n    return path.join(context.workspaceRoot, options.appModuleBundle);\n  }\n\n  const { baseOutputPath = '' } = serverResult;\n  const outputPath = path.join(baseOutputPath, browserLocaleDirectory);\n\n  if (!fs.existsSync(outputPath)) {\n    throw new Error(`Could not find server output directory: ${outputPath}.`);\n  }\n\n  const re = /^main\\.(?:[a-zA-Z0-9]{16}\\.)?js$/;\n  const maybeMain = fs.readdirSync(outputPath).find((x) => re.test(x));\n\n  if (!maybeMain) {\n    throw new Error('Could not find the main bundle.');\n  }\n\n  return path.join(outputPath, maybeMain);\n}\n\nasync function _appShellBuilder(\n  options: BuildWebpackAppShellSchema,\n  context: BuilderContext,\n): Promise<BuilderOutput> {\n  context.logger.warn(\n    'The \"@angular-devkit/build-angular:app-shell\" builder is deprecated as part of Angular\\'s Webpack support deprecation. ' +","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/build_angular/src/builders/app-shell/index.ts#L130-L166","documentation":"The app-shell builder runs a server build and then looks for the compiled server output directory (server dist path joined with the locale directory) to locate the server main bundle for prerendering. If that directory does not exist on disk at the expected path, it throws. This usually means the server build output was not produced where the builder expected it.","triggerScenarios":"Running the app-shell builder where the server target builds to a different outputPath/baseOutputPath than expected, the server build succeeded but wrote nothing (wrong outputPath in server architect target config), a custom browserLocaleDirectory was injected but the built output has no such subdirectory, or the server build output was deleted between build and lookup.","commonSituations":"Customizing serverTarget output path in angular.json and forgetting to align it; monorepo setups where outputs are redirected (e.g. to a shared dist root) so the computed joined path is wrong; localization configurations creating unexpected locale subfolders; running with a cached/stale build result object.","solutions":["Verify the server target (serverTarget option) actually builds and note its outputPath (run it standalone: ng run app:server).","Align the server target's outputPath in angular.json so the server main.js lands where app-shell expects (or set serverTarget output paths explicitly).","Check whether localization/locale directory config causes the outputPath to include a locale subfolder that does not exist; adjust locales or output structure.","Clean dist output and rerun so no stale build result points at deleted directories."],"exampleFix":"// before (angular.json, server target)\n\"options\": { \"outputPath\": \"dist/my-app/server-custom\" }\n// after\n\"options\": { \"outputPath\": \"dist/my-app/server\" }","handlingStrategy":"validation","validationCode":"import * as fs from 'fs';\nimport * as path from 'path';\nconst serverOut = path.join(serverBaseOutputPath, browserLocaleDirectory);\nif (!fs.existsSync(serverOut)) {\n  throw new Error(`Server output missing before app-shell run: ${serverOut}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await runAppShell();\n} catch (e) {\n  if (String(e.message).includes('Could not find server output directory')) {\n    // rebuild server target / fix outputPath before retrying\n  }\n  throw e;\n}","preventionTips":["Keep the server target outputPath aligned with what app-shell computes","Run the server target standalone to verify output before app-shell","Avoid manually deleting dist folders referenced by build results","Pin output paths explicitly in angular.json instead of defaults"],"tags":["angular","app-shell","build","filesystem","path"],"backgroundTag":"build-output-directory-missing","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}