{"record":{"id":"fc3c9b8a3807bf95","repo":"microsoft/aspire","slug":"the-next-js-config-file-configfilename-does-not-contain","errorCode":null,"errorMessage":"The Next.js config file '{configFileName}' does not contain 'output: \"standalone\"'. AddNextJsApp requires Next.js standalone output mode to generate a working Dockerfile. Add 'output: \"standalone\"' to the nextConfig object in your Next.js config file.","messagePattern":"The Next\\.js config file '(.+?)' does not contain 'output: \"standalone\"'\\. AddNextJsApp requires Next\\.js standalone output mode to generate a working Dockerfile\\. Add 'output: \"standalone\"' to the nextConfig object in your Next\\.js config file\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs","lineNumber":3174,"sourceCode":"    /// </summary>\n    internal static void ValidateNextJsStandaloneOutput(string appDirectory)\n    {\n        foreach (var configFileName in s_nextConfigFileNames)\n        {\n            var configPath = Path.Combine(appDirectory, configFileName);\n            if (!File.Exists(configPath))\n            {\n                continue;\n            }\n\n            try\n            {\n                var content = File.ReadAllText(configPath);\n\n                // Check for quoted \"standalone\" (double or single quotes) to reduce false positives\n                if (!content.Contains(\"\\\"standalone\\\"\") && !content.Contains(\"'standalone'\"))\n                {\n                    throw new InvalidOperationException(\n                        $\"The Next.js config file '{configFileName}' does not contain 'output: \\\"standalone\\\"'. \" +\n                        \"AddNextJsApp requires Next.js standalone output mode to generate a working Dockerfile. \" +\n                        \"Add 'output: \\\"standalone\\\"' to the nextConfig object in your Next.js config file.\");\n                }\n            }\n            catch (IOException)\n            {\n                // If we can't read the config, skip the check — the Docker build will surface the error.\n            }\n\n            return;\n        }\n\n        throw new InvalidOperationException(\n            \"No Next.js configuration file found. AddNextJsApp expects one of: \" +\n            string.Join(\", \", s_nextConfigFileNames));\n    }\n","sourceCodeStart":3156,"sourceCodeEnd":3192,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs#L3156-L3192","documentation":"AddNextJsApp generates a Dockerfile that depends on Next.js standalone output (which emits a self-contained server into .next/standalone). The library reads the Next.js config file at model-build time and throws if it cannot find an 'output: \"standalone\"' setting, because without it the published container would not run.","triggerScenarios":"Calling AddNextJsApp when next.config.js/.mjs/.ts exists but lacks output:\"standalone\" (or uses unquoted standalone — the check only matches \"standalone\" or 'standalone' literals, so output: standalone without quotes fails the Contains check).","commonSituations":"Scaffolding a new Next.js app with create-next-app (defaults to no standalone output); manually-written config with output: standalone unquoted (TypeScript-valid but fails this string check); config file unreadable is skipped, but a readable file missing the flag throws.","solutions":["Add output: \"standalone\" to the nextConfig object in next.config.js/.mjs/.ts.","Quote the standalone value (output: \"standalone\" or output: 'standalone') — unquoted output: standalone will not satisfy the string check in some validation paths.","Re-run the AppHost after saving the config change."],"exampleFix":"// before (next.config.js)\nconst nextConfig = {};\n// after\nconst nextConfig = { output: \"standalone\" };","handlingStrategy":"validation","validationCode":"var config = File.ReadAllText(Path.Combine(appDir, \"next.config.mjs\"));\nif (!config.Contains(\"\\\"standalone\\\"\") && !config.Contains(\"'standalone'\"))\n    throw new InvalidOperationException(\"next.config must set output: \\\"standalone\\\" (quoted).\");","typeGuard":null,"tryCatchPattern":"try { builder.AddNextJsApp(\"web\", \"./web\"); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"standalone\")) { /* fix next.config and re-run */ }","preventionTips":["Scaffold Next.js apps with output: \"standalone\" in the config template.","Keep the value quoted — the check matches quoted literals only.","Validate configs in CI before running the AppHost."],"tags":["javascript","nextjs","docker","config"],"backgroundTag":"invalid-config-value","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}