{"record":{"id":"19d9bceacb309c84","repo":"microsoft/aspire","slug":"publishaspackagescript-requires-a-deno-package-manager-add-a-19d9bc","errorCode":null,"errorMessage":"PublishAsPackageScript requires a Deno package manager. Add a deno.json file or call WithDeno().","messagePattern":"PublishAsPackageScript requires a Deno package manager\\. Add a deno\\.json file or call WithDeno\\(\\)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs","lineNumber":927,"sourceCode":"                    // Deno ships its own runtime, so both stages default to the same Deno image. Unlike the Bun\n                    // variant there is no separate production-dependency install stage: Deno caches remote and\n                    // npm dependencies under DENO_DIR. Direct run/serve entrypoints pre-populate that cache in\n                    // the build stage and use --cached-only at runtime. Task entrypoints are opaque shell\n                    // commands in deno.json, so Aspire cannot safely infer their module graph.\n                    var baseBuildImage = baseImageAnnotation?.BuildImage ?? DefaultDenoImage;\n                    var buildStage = dockerfileContext.Builder\n                        .From(baseBuildImage, \"build\");\n\n                    // Package-script builds install from the manifest layer before copying the remaining source.\n                    // Direct run/serve builds copy the full module graph first, then cache it with the same\n                    // resolution and lock flags used by the runtime entrypoint.\n                    dockerfileContext.Resource.TryGetLastAnnotation<JavaScriptPublishModeAnnotation>(out var publishMode);\n                    if (publishMode?.Mode == JavaScriptPublishMode.PackageScript)\n                    {\n                        if (!dockerfileContext.Resource.TryGetLastAnnotation<JavaScriptPackageManagerAnnotation>(out var packageManager) ||\n                            !dockerfileContext.Resource.TryGetLastAnnotation<JavaScriptInstallCommandAnnotation>(out var installCommand))\n                        {\n                            throw new InvalidOperationException(\"PublishAsPackageScript requires a Deno package manager. Add a deno.json file or call WithDeno().\");\n                        }\n\n                        buildStage.EmptyLine();\n                        packageManager.InitializeDockerBuildStage?.Invoke(buildStage);\n                        buildStage\n                            .EmptyLine()\n                            .WorkDir(\"/app\");\n\n                        var copiedAllSource = buildStage.CopyPackageFilesForInstall(packageManager);\n                        buildStage.AddInstallCommand(packageManager, installCommand);\n\n                        if (!copiedAllSource)\n                        {\n                            buildStage.Copy(\".\", \".\");\n                        }\n                    }\n                    else\n                    {","sourceCodeStart":909,"sourceCodeEnd":945,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs#L909-L945","documentation":"PublishAsPackageScript (JavaScriptPublishMode.PackageScript) for a Deno app depends on package-manager and install-command annotations that only exist when Deno package management is configured. During Dockerfile generation in AddDenoApp, if those annotations are missing, the library cannot emit the package-script build stage and throws.","triggerScenarios":"Calling PublishAsPackageScript() on a JavaScript/Deno app resource that has no deno.json (so no Deno package manager annotation is inferred) and no explicit WithDeno() call, then generating its Dockerfile.","commonSituations":"A Deno project without a deno.json file relying on defaults; forgetting WithDeno() after applying PublishAsPackageScript; a resource where package-manager detection failed silently.","solutions":["Add a deno.json file to the application directory so the Deno package manager is detected.","Call WithDeno() on the resource to configure Deno package management explicitly.","Remove PublishAsPackageScript() if the resource is not actually a Deno package-script app."],"exampleFix":"// before\nbuilder.AddJavaScriptApp(\"pkg\", \"main.ts\").PublishAsPackageScript();\n// after\nbuilder.AddJavaScriptApp(\"pkg\", \"main.ts\").WithDeno().PublishAsPackageScript();","handlingStrategy":"validation","validationCode":"// ensure Deno package management exists before PublishAsPackageScript\nif (!resource.TryGetLastAnnotation<JavaScriptPackageManagerAnnotation>(out _) ||\n    !resource.TryGetLastAnnotation<JavaScriptInstallCommandAnnotation>(out _))\n{\n    resource.WithDeno(); // or ensure a deno.json exists in the app directory\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    app.WithDeno().PublishAsPackageScript();\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"PublishAsPackageScript requires a Deno package manager\"))\n{\n    // add deno.json or call WithDeno() first\n}","preventionTips":["Always create a deno.json in Deno projects so package management is detectable.","Chain WithDeno() before PublishAsPackageScript() as a habit.","Verify package-manager detection succeeded when using conditional resource setup."],"tags":["deno","publish","package-script","missing-dependency"],"backgroundTag":"missing-dependency","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}