{"record":{"id":"4dbd6db601045f1f","repo":"microsoft/aspire","slug":"unsupported-deno-node-modules-mode-mode","errorCode":null,"errorMessage":"Unsupported Deno node_modules mode '{mode}'.","messagePattern":"Unsupported Deno node_modules mode '(.+?)'\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.JavaScript/DenoHostingExtensions.cs","lineNumber":701,"sourceCode":"        {\n            yield return \"--lock\";\n            yield return deno.Lock;\n        }\n\n        if (deno.NodeModulesDirSet)\n        {\n            yield return deno.NodeModulesDirMode is not { } mode\n                ? \"--node-modules-dir\"\n                : $\"--node-modules-dir={GetDenoNodeModulesDirModeValue(mode)}\";\n        }\n    }\n\n    private static string GetDenoNodeModulesDirModeValue(DenoNodeModulesDirMode mode) => mode switch\n    {\n        DenoNodeModulesDirMode.None => \"none\",\n        DenoNodeModulesDirMode.Auto => \"auto\",\n        DenoNodeModulesDirMode.Manual => \"manual\",\n        _ => throw new InvalidOperationException($\"Unsupported Deno node_modules mode '{mode}'.\"),\n    };\n\n    private static void AppendUnstableFlags(List<object> args, DenoCommandLineAnnotation deno)\n    {\n        foreach (var flag in deno.UnstableFlags)\n        {\n            args.Add(flag);\n        }\n    }\n\n    /// <summary>\n    /// Rejects <see cref=\"WithDenoRuntimeArgs(IResourceBuilder{DenoAppResource}, string[])\"/> entries that\n    /// collide with a flag Aspire already emits for this resource.\n    /// </summary>\n    /// <remarks>\n    /// Verified against Deno 2.9.0: single-occurrence options fail with\n    /// <c>error: the argument '--config &lt;FILE&gt;' cannot be used multiple times</c>, and mutually exclusive\n    /// pairs (<c>--config</c> with <c>--no-config</c>, <c>--no-lock</c> with <c>--lock</c>,","sourceCodeStart":683,"sourceCodeEnd":719,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.JavaScript/DenoHostingExtensions.cs#L683-L719","documentation":"GetDenoNodeModulesDirModeValue converts a DenoNodeModulesDirMode into the Deno CLI value ('none'/'auto'/'manual') when building args. Hitting the discard arm with InvalidOperationException is an internal invariant violation: the API-time validation (error 1014) should have rejected any undefined mode, so this signals a new enum member whose mapping was not added, or a value injected via a mismatched assembly.","triggerScenarios":"A newly added DenoNodeModulesDirMode member not mapped in GetDenoNodeModulesDirModeValue; mixed-version assemblies where the enum and the mapping differ; bypassing WithDenoNodeModulesDir and setting annotation.NodeModulesDirMode directly.","commonSituations":"Running an upgraded Aspire.Hosting.JavaScript against cached older binaries (or vice versa); custom code writing to the Deno annotation directly.","solutions":["Upgrade all Aspire.* packages to the same version and rebuild.","Do not set NodeModulesDirMode on the annotation directly; use WithDenoNodeModulesDir.","If you added a new DenoNodeModulesDirMode member, add its mapping to GetDenoNodeModulesDirModeValue and file/fix the library bug.","Clear stale build artifacts (bin/obj) and restore to eliminate mixed-version binaries."],"exampleFix":"// before\ndeno.NodeModulesDirMode = (DenoNodeModulesDirMode)9;\n// after\nbuilder.WithDenoNodeModulesDir(DenoNodeModulesDirMode.Manual);","handlingStrategy":"validation","validationCode":"if (mode is not null && !Enum.IsDefined(mode.Value)) throw new ArgumentException(\"Unsupported DenoNodeModulesDirMode before launch.\");","typeGuard":null,"tryCatchPattern":"try { app.Run(); } catch (InvalidOperationException ex) when (ex.Message.Contains(\"Unsupported Deno node_modules mode\")) { /* report version/config bug */ }","preventionTips":["Always configure modes through the public builder APIs","Keep Aspire package versions uniform across the solution","Clean bin/obj after upgrading packages"],"tags":["invalid-operation-exception","deno","enum","internal-invariant"],"backgroundTag":"internal-invariant-violation","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"}