{"id":"f83215e3f424d7f2","repo":"gohugoio/hugo","slug":"unsupported-platform-type-q","errorCode":null,"errorMessage":"unsupported platform type: %q","messagePattern":"unsupported platform type: %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/js/esbuild/options.go","lineNumber":380,"sourceCode":"\tcase \"preserve\":\n\t\tjsx = api.JSXPreserve\n\tcase \"automatic\":\n\t\tjsx = api.JSXAutomatic\n\tdefault:\n\t\terr = fmt.Errorf(\"unsupported jsx type: %q\", opts.JSX)\n\t\treturn\n\t}\n\n\tvar platform api.Platform\n\tswitch opts.Platform {\n\tcase \"\", \"browser\":\n\t\tplatform = api.PlatformBrowser\n\tcase \"node\":\n\t\tplatform = api.PlatformNode\n\tcase \"neutral\":\n\t\tplatform = api.PlatformNeutral\n\tdefault:\n\t\terr = fmt.Errorf(\"unsupported platform type: %q\", opts.Platform)\n\t\treturn\n\t}\n\n\tvar defines map[string]string\n\tif opts.Defines != nil {\n\t\tdefines = hmaps.ToStringMapString(opts.Defines)\n\t}\n\n\tvar drop api.Drop\n\tswitch opts.Drop {\n\tcase \"\":\n\tcase \"console\":\n\t\tdrop = api.DropConsole\n\tcase \"debugger\":\n\t\tdrop = api.DropDebugger\n\tdefault:\n\t\terr = fmt.Errorf(\"unsupported drop type: %q\", opts.Drop)\n\t}","sourceCodeStart":362,"sourceCodeEnd":398,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/internal/js/esbuild/options.go#L362-L398","documentation":"The `platform` option selects esbuild's target platform, which affects package.json main-field resolution, default output conventions, and how built-ins are treated. Hugo accepts only \"\" or \"browser\" (default), \"node\", and \"neutral\"; other values abort with this error.","triggerScenarios":"Passing `dict \"platform\" \"web\"`, \"nodejs\", \"deno\", or any string other than browser/node/neutral to js.Build/js.Batch options.","commonSituations":"Writing \"web\" out of habit from other tools; \"nodejs\" instead of \"node\"; casing mistakes like \"Browser\" won't fail (option keys are case-insensitive but values are not) — the value must be exact lowercase.","solutions":["Use \"browser\", \"node\", or \"neutral\" as the platform value.","Remove the option to default to \"browser\", which is correct for almost all Hugo sites.","If targeting a runtime-agnostic library build, use \"neutral\"."],"exampleFix":"{{/* before */}}\n{{ $js := resources.Get \"main.js\" | js.Build (dict \"platform\" \"web\") }}\n{{/* after */}}\n{{ $js := resources.Get \"main.js\" | js.Build (dict \"platform\" \"browser\") }}","handlingStrategy":"validation","validationCode":"validPlatforms := map[string]bool{\"browser\": true, \"node\": true, \"neutral\": true}\nif opts.Platform != \"\" && !validPlatforms[opts.Platform] {\n    return fmt.Errorf(\"invalid platform %q; must be browser, node, or neutral\", opts.Platform)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Stick to browser (default), node, or neutral for the platform option.","For code shipped to a website, omit platform entirely and take the browser default.","Validate option maps passed through dict/site params before they reach js.Build."],"tags":["hugo","esbuild","platform","config"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}