{"record":{"id":"bf749a77c2affa71","repo":"microsoft/aspire","slug":"generated-deno-dockerfiles-do-not-support-alternate-package","errorCode":null,"errorMessage":"Generated Deno Dockerfiles do not support alternate package manager '{packageManager.ExecutableName}'. Use WithDeno() or provide a custom Dockerfile.","messagePattern":"Generated Deno Dockerfiles do not support alternate package manager '(.+?)'\\. Use WithDeno\\(\\) or provide a custom Dockerfile\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.JavaScript/DenoHostingExtensions.cs","lineNumber":960,"sourceCode":"        NormalizeDenoContainerPathArguments(entrypoint);\n        return [.. entrypoint];\n    }\n\n    private static void ThrowIfUnsupportedDenoDockerfileOptions(IResource resource)\n    {\n        if (resource.TryGetLastAnnotation<JavaScriptPublishModeAnnotation>(out var publishMode) &&\n            publishMode.Mode is JavaScriptPublishMode.StaticWebsite or JavaScriptPublishMode.NodeServer)\n        {\n            var publishMethod = publishMode.Mode == JavaScriptPublishMode.StaticWebsite\n                ? nameof(PublishAsStaticWebsite)\n                : nameof(PublishAsNodeServer);\n            throw new InvalidOperationException($\"Generated Deno Dockerfiles do not support {publishMethod}. Use AddJavaScriptApp(...).WithDeno() or provide a custom Dockerfile.\");\n        }\n\n        if (resource.TryGetLastAnnotation<JavaScriptPackageManagerAnnotation>(out var packageManager) &&\n            !string.Equals(packageManager.ExecutableName, \"deno\", StringComparison.Ordinal))\n        {\n            throw new InvalidOperationException($\"Generated Deno Dockerfiles do not support alternate package manager '{packageManager.ExecutableName}'. Use WithDeno() or provide a custom Dockerfile.\");\n        }\n\n        if (resource.TryGetLastAnnotation<DenoCommandLineAnnotation>(out var deno) &&\n            deno.NodeModulesDirSet &&\n            deno.NodeModulesDirMode == DenoNodeModulesDirMode.Manual)\n        {\n            throw new InvalidOperationException(\"The 'manual' node_modules mode is not supported by generated Deno Dockerfiles because node_modules is excluded from the build context. Use the 'auto' mode or provide a custom Dockerfile.\");\n        }\n\n        if (deno is not null)\n        {\n            if (deno.RuntimeArgs.Any(argument =>\n                argument == \"--env-file\" ||\n                argument.StartsWith(\"--env-file=\", StringComparison.Ordinal)))\n            {\n                throw new InvalidOperationException(\n                    \"Generated Deno Dockerfiles do not support '--env-file' because dotenv files can contain secrets that would be copied into the container image. Use Aspire environment variables or secret parameters, or provide a custom Dockerfile that handles the file securely.\");\n            }","sourceCodeStart":942,"sourceCodeEnd":978,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.JavaScript/DenoHostingExtensions.cs#L942-L978","documentation":"The generated Deno Dockerfile assumes the package manager is deno itself. If the resource has a JavaScriptPackageManagerAnnotation whose ExecutableName is not \"deno\" (e.g. npm, pnpm, yarn, bun), the generated image cannot run it, so ThrowIfUnsupportedDenoDockerfileOptions throws at build/publish time.","triggerScenarios":"Configuring a resource whose Dockerfile is Deno-generated while a non-deno package manager annotation is present — e.g. calling WithNpm()/WithPnpm() (or the package manager being inferred from package.json) on a resource built via WithDeno(), then generating the Dockerfile.","commonSituations":"A project folder contains package.json so Aspire auto-detects npm while the developer also calls WithDeno(); switching a shared resource between package managers without removing the old annotation.","solutions":["Remove the alternate package manager configuration (WithNpm/WithPnpm/WithYarn/WithBun) from the resource.","Call WithDeno() to explicitly select Deno and the generated Deno Dockerfile path.","Provide a custom Dockerfile if you genuinely need another package manager inside the image."],"exampleFix":"// before\nbuilder.AddJavaScriptApp(\"api\", \"main.ts\").WithNpm();\n// after\nbuilder.AddJavaScriptApp(\"api\", \"main.ts\").WithDeno();","handlingStrategy":"validation","validationCode":"// ensure the package manager is deno before relying on generated Deno Dockerfiles\nif (resource.TryGetLastAnnotation<JavaScriptPackageManagerAnnotation>(out var pm) &&\n    !string.Equals(pm.ExecutableName, \"deno\", StringComparison.Ordinal))\n{\n    throw new InvalidOperationException($\"{pm.ExecutableName} is not supported by generated Deno Dockerfiles.\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    resourceBuilder.WithDeno();\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"alternate package manager\"))\n{\n    // drop the npm/pnpm/yarn/bun annotation or use a custom Dockerfile\n}","preventionTips":["Check whether the project directory contains package.json before choosing Deno; auto-detection may pick npm.","Explicitly call WithDeno() instead of relying on inference when the app is Deno-based.","Only one package manager per resource — remove prior WithNpm/WithPnpm calls."],"tags":["deno","dockerfile","package-manager","configuration-conflict"],"backgroundTag":"conflicting-config-options","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"}