microsoft/aspire · error · InvalidOperationException
Generated Deno Dockerfiles do not support alternate package…
Error message
Generated Deno Dockerfiles do not support alternate package manager '{packageManager.ExecutableName}'. Use WithDeno() or provide a custom Dockerfile. What it means
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.
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.
Example fix
// before
builder.AddJavaScriptApp("api", "main.ts").WithNpm();
// after
builder.AddJavaScriptApp("api", "main.ts").WithDeno(); Defensive patterns
Strategy: validation
Validate before calling
// ensure the package manager is deno before relying on generated Deno Dockerfiles
if (resource.TryGetLastAnnotation<JavaScriptPackageManagerAnnotation>(out var pm) &&
!string.Equals(pm.ExecutableName, "deno", StringComparison.Ordinal))
{
throw new InvalidOperationException($"{pm.ExecutableName} is not supported by generated Deno Dockerfiles.");
} Try / catch
try
{
resourceBuilder.WithDeno();
}
catch (InvalidOperationException ex) when (ex.Message.Contains("alternate package manager"))
{
// drop the npm/pnpm/yarn/bun annotation or use a custom Dockerfile
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- Deno command-line options configured with the WithDeno*…
- Generated Deno Dockerfiles do not support
- Generated Deno Dockerfiles do not support '--env-file'…
- Package manager ' ' does not have ProductionInstallArgs…
- The 'manual' node_modules mode is not supported by…
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/bf749a77c2affa71.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.JavaScript/DenoHostingExtensions.cs:960
NormalizeDenoContainerPathArguments(entrypoint);
return [.. entrypoint];
}
private static void ThrowIfUnsupportedDenoDockerfileOptions(IResource resource)
{
if (resource.TryGetLastAnnotation<JavaScriptPublishModeAnnotation>(out var publishMode) &&
publishMode.Mode is JavaScriptPublishMode.StaticWebsite or JavaScriptPublishMode.NodeServer)
{
var publishMethod = publishMode.Mode == JavaScriptPublishMode.StaticWebsite
? nameof(PublishAsStaticWebsite)
: nameof(PublishAsNodeServer);
throw new InvalidOperationException($"Generated Deno Dockerfiles do not support {publishMethod}. Use AddJavaScriptApp(...).WithDeno() or provide a custom Dockerfile.");
}
if (resource.TryGetLastAnnotation<JavaScriptPackageManagerAnnotation>(out var packageManager) &&
!string.Equals(packageManager.ExecutableName, "deno", StringComparison.Ordinal))
{
throw new InvalidOperationException($"Generated Deno Dockerfiles do not support alternate package manager '{packageManager.ExecutableName}'. Use WithDeno() or provide a custom Dockerfile.");
}
if (resource.TryGetLastAnnotation<DenoCommandLineAnnotation>(out var deno) &&
deno.NodeModulesDirSet &&
deno.NodeModulesDirMode == DenoNodeModulesDirMode.Manual)
{
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.");
}
if (deno is not null)
{
if (deno.RuntimeArgs.Any(argument =>
argument == "--env-file" ||
argument.StartsWith("--env-file=", StringComparison.Ordinal)))
{
throw new InvalidOperationException(
"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.");
}View on GitHub (pinned to 25830f84bd)