microsoft/aspire · error · InvalidOperationException
Deno command-line options configured with the WithDeno*…
Error message
Deno command-line options configured with the WithDeno* methods cannot be combined with package manager '{packageManager.ExecutableName}' on resource '{resource.Name}'. Remove the WithDeno* options or use WithDeno(). What it means
Deno-specific command-line options (WithDeno* methods producing a DenoCommandLineAnnotation) are only meaningful when the resource's package manager is deno. Combining them with another package manager produces a contradictory configuration, so AddDenoApp throws when both a DenoCommandLineAnnotation and a non-deno JavaScriptPackageManagerAnnotation are present.
Solutions
- Remove the WithDeno* option calls from the resource.
- Call WithDeno() to switch the resource's package manager to deno before applying Deno options.
- Delete the stale package-manager annotation/detection source (e.g. remove package.json or stop auto-detection) if it is leftover.
Example fix
// before
builder.AddJavaScriptApp("app", "main.ts").WithNpm().WithDenoConfig("deno.json");
// after
builder.AddJavaScriptApp("app", "main.ts").WithDeno(deno => deno.WithConfig("deno.json")); Defensive patterns
Strategy: validation
Validate before calling
// detect the conflict before calling WithDeno* methods
var hasDenoOptions = resource.TryGetLastAnnotation<DenoCommandLineAnnotation>(out _);
resource.TryGetLastAnnotation<JavaScriptPackageManagerAnnotation>(out var pm);
if (hasDenoOptions && pm is not null && pm.ExecutableName != "deno")
{
throw new InvalidOperationException($"Deno options conflict with package manager {pm.ExecutableName}.");
} Try / catch
try
{
app.WithDeno(deno => deno.WithConfig("deno.json"));
}
catch (InvalidOperationException ex) when (ex.Message.Contains("cannot be combined with package manager"))
{
// drop the WithDeno* options or switch the resource to WithDeno()
} Prevention
- Decide the package manager once per resource before applying command-line options.
- Call WithDeno() before any WithDeno* option methods.
- Remove leftover package.json/npm configuration when converting an app to Deno.
When it happens
Trigger: Calling WithDeno* options (e.g. WithDenoConfig, WithDenoScript, WithDenoNodeModules) on a resource whose package manager annotation resolves to npm/pnpm/yarn/bun — for example AddJavaScriptApp on a package.json project, then adding Deno options.
Common situations: Refactoring a Node app to Deno where package.json still drives package-manager detection; a shared helper that appends Deno flags to every JavaScript resource; typos where WithDeno() was meant to be called instead.
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
- Generated Deno Dockerfiles do not support alternate package…
- Generated Deno Dockerfiles do not support
- WithBuildScript requires a Deno package manager. Add a…
- ASPIRERADIUS011
- Conflicting values for 'CommandTimeout' were found in
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/365101659d710d4f.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.JavaScript/DenoHostingExtensions.cs:1065
normalizedSegments.Add(segment);
}
normalizedPath = string.Join('/', normalizedSegments);
return true;
}
/// <summary>
/// Rejects Deno-specific command-line options when a non-Deno package manager is the effective launcher.
/// The <c>WithDeno*</c> flags produce a Deno argument vector (for example <c>run -A --watch main.ts</c>),
/// which is meaningless once the command is switched to another package manager such as <c>npm</c>.
/// </summary>
private static void ThrowIfDenoOptionsConflictWithPackageManager(IResource resource)
{
if (resource.TryGetLastAnnotation<DenoCommandLineAnnotation>(out _) &&
resource.TryGetLastAnnotation<JavaScriptPackageManagerAnnotation>(out var packageManager) &&
!string.Equals(packageManager.ExecutableName, "deno", StringComparison.Ordinal))
{
throw new InvalidOperationException($"Deno command-line options configured with the WithDeno* methods cannot be combined with package manager '{packageManager.ExecutableName}' on resource '{resource.Name}'. Remove the WithDeno* options or use WithDeno().");
}
}
/// <summary>
/// Converts a host-relative path to normalized POSIX form for the generated Linux container stages.
/// </summary>
/// <remarks>
/// AppHost-configured paths use the host separator, so on Windows a nested entrypoint is configured as
/// <c>src\main.ts</c>. Emitting that verbatim into <c>deno cache</c> or <c>ENTRYPOINT</c> makes Linux treat
/// the whole string as a single file name and the container fails to start.
/// </remarks>
private static string ToDenoContainerPath(string path)
=> TryNormalizeDenoContainerRelativePath(path, out var normalizedPath)
? normalizedPath
: path.Replace('\\', '/');
// Deno options that Aspire emits as a separate flag/value pair where the value is a path that must be
// rewritten to its container form.View on GitHub (pinned to 25830f84bd)