{"record":{"id":"365101659d710d4f","repo":"microsoft/aspire","slug":"deno-command-line-options-configured-with-the-withdeno","errorCode":null,"errorMessage":"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().","messagePattern":"Deno command-line options configured with the WithDeno\\* methods cannot be combined with package manager '(.+?)' on resource '(.+?)'\\. Remove the WithDeno\\* options or use WithDeno\\(\\)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.JavaScript/DenoHostingExtensions.cs","lineNumber":1065,"sourceCode":"            normalizedSegments.Add(segment);\n        }\n\n        normalizedPath = string.Join('/', normalizedSegments);\n        return true;\n    }\n\n    /// <summary>\n    /// Rejects Deno-specific command-line options when a non-Deno package manager is the effective launcher.\n    /// The <c>WithDeno*</c> flags produce a Deno argument vector (for example <c>run -A --watch main.ts</c>),\n    /// which is meaningless once the command is switched to another package manager such as <c>npm</c>.\n    /// </summary>\n    private static void ThrowIfDenoOptionsConflictWithPackageManager(IResource resource)\n    {\n        if (resource.TryGetLastAnnotation<DenoCommandLineAnnotation>(out _) &&\n            resource.TryGetLastAnnotation<JavaScriptPackageManagerAnnotation>(out var packageManager) &&\n            !string.Equals(packageManager.ExecutableName, \"deno\", StringComparison.Ordinal))\n        {\n            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().\");\n        }\n    }\n\n    /// <summary>\n    /// Converts a host-relative path to normalized POSIX form for the generated Linux container stages.\n    /// </summary>\n    /// <remarks>\n    /// AppHost-configured paths use the host separator, so on Windows a nested entrypoint is configured as\n    /// <c>src\\main.ts</c>. Emitting that verbatim into <c>deno cache</c> or <c>ENTRYPOINT</c> makes Linux treat\n    /// the whole string as a single file name and the container fails to start.\n    /// </remarks>\n    private static string ToDenoContainerPath(string path)\n        => TryNormalizeDenoContainerRelativePath(path, out var normalizedPath)\n            ? normalizedPath\n            : path.Replace('\\\\', '/');\n\n    // Deno options that Aspire emits as a separate flag/value pair where the value is a path that must be\n    // rewritten to its container form.","sourceCodeStart":1047,"sourceCodeEnd":1083,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.JavaScript/DenoHostingExtensions.cs#L1047-L1083","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nbuilder.AddJavaScriptApp(\"app\", \"main.ts\").WithNpm().WithDenoConfig(\"deno.json\");\n// after\nbuilder.AddJavaScriptApp(\"app\", \"main.ts\").WithDeno(deno => deno.WithConfig(\"deno.json\"));","handlingStrategy":"validation","validationCode":"// detect the conflict before calling WithDeno* methods\nvar hasDenoOptions = resource.TryGetLastAnnotation<DenoCommandLineAnnotation>(out _);\nresource.TryGetLastAnnotation<JavaScriptPackageManagerAnnotation>(out var pm);\nif (hasDenoOptions && pm is not null && pm.ExecutableName != \"deno\")\n{\n    throw new InvalidOperationException($\"Deno options conflict with package manager {pm.ExecutableName}.\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    app.WithDeno(deno => deno.WithConfig(\"deno.json\"));\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"cannot be combined with package manager\"))\n{\n    // drop the WithDeno* options or switch the resource to WithDeno()\n}","preventionTips":["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."],"tags":["deno","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"}