{"record":{"id":"affb54c38fd6ec97","repo":"microsoft/aspire","slug":"the-manual-node-modules-mode-is-not-supported-by-generated","errorCode":null,"errorMessage":"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.","messagePattern":"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\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.JavaScript/DenoHostingExtensions.cs","lineNumber":967,"sourceCode":"            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            }\n\n            // The Docker build context is the app directory, so a path that is absolute or escapes the app\n            // directory is never copied into the image and would break both `deno cache` and the entrypoint.\n            ThrowIfPathEscapesDenoBuildContext(deno.ConfigFile, nameof(WithDenoConfig));\n            ThrowIfPathEscapesDenoBuildContext(deno.ImportMap, nameof(WithDenoImportMap));\n            ThrowIfPathEscapesDenoBuildContext(deno.Lock, nameof(WithDenoLock));\n        }","sourceCodeStart":949,"sourceCodeEnd":985,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.JavaScript/DenoHostingExtensions.cs#L949-L985","documentation":"Deno's \"manual\" node_modules mode relies on a node_modules directory that the generated Docker build deliberately excludes from the build context (via .dockerignore). The image therefore cannot contain the files Deno needs, so the library throws instead of producing a broken image.","triggerScenarios":"Calling WithDeno(...) with an explicit node_modules configuration setting DenoNodeModulesDirMode.Manual (or setting the equivalent deno.json/vendor option so DenoCommandLineAnnotation has NodeModulesDirSet=true and mode Manual), then generating the Dockerfile.","commonSituations":"Migrating a local Deno project that used --node-modules-dir=manual into container publish; a deno.json vendoring setup copied from a non-containerized workflow.","solutions":["Switch the node_modules mode to auto (or remove the explicit setting to use the default).","Remove WithDenoNodeModules / the manual-mode configuration from the resource.","Provide a custom Dockerfile that copies or creates node_modules yourself if manual mode is required."],"exampleFix":"// before\n.WithDeno(deno => deno.WithNodeModulesDir(DenoNodeModulesDirMode.Manual))\n// after\n.WithDeno(deno => deno.WithNodeModulesDir(DenoNodeModulesDirMode.Auto))","handlingStrategy":"validation","validationCode":"// reject manual node_modules mode before generating a Deno Dockerfile\nif (deno is { NodeModulesDirSet: true, NodeModulesDirMode: DenoNodeModulesDirMode.Manual })\n{\n    throw new InvalidOperationException(\"Use DenoNodeModulesDirMode.Auto for generated Deno Dockerfiles.\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    app.WithDeno(deno => deno.WithNodeModulesDir(DenoNodeModulesDirMode.Auto));\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"'manual' node_modules mode\"))\n{\n    // switch to Auto or supply a custom Dockerfile\n}","preventionTips":["Use the default or 'auto' node_modules mode for containerized Deno apps.","Reserve manual mode for local, non-container workflows only.","When migrating a project to containers, review deno.json vendoring options first."],"tags":["deno","dockerfile","node-modules","build-context"],"backgroundTag":"unsupported-config-value","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"}