{"record":{"id":"c6541484b52a5155","repo":"microsoft/aspire","slug":"package-manager-packagemanager-executablename-does-not-have","errorCode":null,"errorMessage":"Package manager '{packageManager.ExecutableName}' does not have ProductionInstallArgs configured, which is required for PublishAsPackageScript.","messagePattern":"Package manager '(.+?)' does not have ProductionInstallArgs configured, which is required for PublishAsPackageScript\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs","lineNumber":1838,"sourceCode":"                                if (packageManager.PackageFilesPatterns.Count > 0)\n                                {\n                                    foreach (var packageFilePattern in packageManager.PackageFilesPatterns)\n                                    {\n                                        prodDepsStage.Copy(packageFilePattern.Source, packageFilePattern.Destination);\n                                    }\n                                }\n                                else\n                                {\n                                    prodDepsStage.Copy(\"package*.json\", \"./\");\n                                }\n\n                                // Install production-only dependencies using the same base install\n                                // command as the build stage (e.g. 'ci' for npm, 'install --frozen-lockfile'\n                                // for pnpm) plus the production-only flag (e.g. '--omit=dev').\n                                var installAnnotation = c.Resource.TryGetLastAnnotation<JavaScriptInstallCommandAnnotation>(out var installCmd) ? installCmd : null;\n                                if (string.IsNullOrEmpty(installAnnotation?.ProductionInstallArgs))\n                                {\n                                    throw new InvalidOperationException($\"Package manager '{packageManager.ExecutableName}' does not have ProductionInstallArgs configured, which is required for PublishAsPackageScript.\");\n                                }\n\n                                var prodInstallCmd = BuildProductionInstallCommand(packageManager, installAnnotation);\n                                if (!string.IsNullOrEmpty(packageManager.CacheMount))\n                                {\n                                    prodDepsStage.Run($\"--mount=type=cache,target={packageManager.CacheMount} {prodInstallCmd}\");\n                                }\n                                else\n                                {\n                                    prodDepsStage.Run(prodInstallCmd);\n                                }\n\n                                // Runtime stage: copy build output then overlay prod deps\n                                var runtimeStage = dockerfileContext.Builder\n                                    .From(runtimeImage, \"runtime\")\n                                    .WorkDir(\"/app\")\n                                    .CopyFrom(\"build\", \"/app\", \"/app\")\n                                    .CopyFrom(\"prod-deps\", \"/app/node_modules\", \"./node_modules\");","sourceCodeStart":1820,"sourceCodeEnd":1856,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs#L1820-L1856","documentation":"PublishAsPackageScript builds a container image that reinstalls production-only dependencies in a Dockerfile stage. That stage needs the package manager's ProductionInstallArgs (e.g. '--omit=dev') from JavaScriptInstallCommandAnnotation. The detected package manager does not define them, so Aspire cannot emit a correct production install command and fails instead of publishing an image with dev dependencies.","triggerScenarios":"Calling PublishAsPackageScript on a JavaScript resource whose JavaScriptInstallCommandAnnotation has null/empty ProductionInstallArgs — typically a custom package manager or one overridden via WithInstallCommand without production args.","commonSituations":"Custom package managers registered without full install metadata; overriding the install command and forgetting the production variant; a package manager newer than Aspire's built-in metadata.","solutions":["Use a supported package manager (npm, pnpm, yarn, bun) whose metadata includes ProductionInstallArgs.","If you override the install command via WithInstallCommand, supply production install args (e.g. '--omit=dev').","If genuinely unsupported, publish with a custom Dockerfile instead of PublishAsPackageScript."],"exampleFix":"// before\nappBuilder.WithInstallCommand(\"my-pm\", \"install\"); // no production args\nappBuilder.PublishAsPackageScript();\n// after\nappBuilder.WithInstallCommand(\"my-pm\", \"install\", productionInstallArgs: \"--omit=dev\");\nappBuilder.PublishAsPackageScript();","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(installAnnotation?.ProductionInstallArgs))\n    throw new InvalidOperationException(\"Configure ProductionInstallArgs before PublishAsPackageScript.\");","typeGuard":null,"tryCatchPattern":"try { appBuilder.PublishAsPackageScript(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"ProductionInstallArgs\"))\n{\n    // fall back to a custom Dockerfile or fix the install annotation\n}","preventionTips":["Stick to supported package managers (npm, pnpm, yarn, bun) for published containers.","When overriding install commands, always include production install args.","Review package-manager metadata before using PublishAsPackageScript."],"tags":["aspire","javascript","dockerfile","publish","package-manager"],"backgroundTag":"missing-required-config-field","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"}