{"id":"9ca610dce89770d8","repo":"gohugoio/hugo","slug":"babel-config-q-not-found","errorCode":null,"errorMessage":"babel config %q not found","messagePattern":"babel config %q not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/resource_transformers/babel/babel.go","lineNumber":148,"sourceCode":"\tif t.options.Config != \"\" {\n\t\tconfigFile = t.options.Config\n\t} else {\n\t\tfor _, name := range []string{\"babel.config.js\", \"babel.config.mjs\", \"babel.config.cjs\"} {\n\t\t\tconfigFile = t.rs.BaseFs.ResolveJSConfigFile(name)\n\t\t\tif configFile != \"\" {\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t}\n\n\tif configFile != \"\" {\n\t\tconfigFile = filepath.Clean(configFile)\n\t\t// We need an absolute filename to the config file.\n\t\tif !filepath.IsAbs(configFile) {\n\t\t\tconfigFile = t.rs.BaseFs.ResolveJSConfigFile(configFile)\n\t\t\tif configFile == \"\" && t.options.Config != \"\" {\n\t\t\t\t// Only fail if the user specified config file is not found.\n\t\t\t\treturn fmt.Errorf(\"babel config %q not found\", t.options.Config)\n\t\t\t}\n\t\t}\n\t}\n\n\tctx.ReplaceOutPathExtension(\".js\")\n\n\tvar cmdArgs []any\n\n\tif configFile != \"\" {\n\t\tinfol.Logf(\"use config file %q\", configFile)\n\t\tcmdArgs = []any{\"--config-file\", configFile}\n\t}\n\n\tif optArgs := t.options.toArgs(); len(optArgs) > 0 {\n\t\tcmdArgs = append(cmdArgs, optArgs...)\n\t}\n\tcmdArgs = append(cmdArgs, \"--filename=\"+ctx.SourcePath)\n","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/resources/resource_transformers/babel/babel.go#L130-L166","documentation":"When the babel resource transformer resolves its config file, a user-specified config (the transformer's config option) that cannot be resolved to an existing file via BaseFs.ResolveJSConfigFile produces this error. Hugo only fails for explicitly specified configs; auto-detected babel.config.{js,mjs,cjs} that are absent are silently skipped.","triggerScenarios":"Calling babel with an options map like (dict \"config\" \"myconfig.js\") where that path doesn't exist in the project (or any mounted theme/module filesystem).","commonSituations":"Typo in the config filename; config file located outside the project root or not mounted via module mounts; renaming .babelrc to babel.config.js but pointing the option at the old name; running from a different working directory in CI.","solutions":["Fix the path in the babel options to match the actual file, relative to the project root: {{ $js := $src | babel (dict \"config\" \"babel.config.js\") }}.","Place babel.config.js/.mjs/.cjs in the project root and drop the config option entirely — Hugo auto-detects those names.","If the config lives in a theme/module, ensure it's mounted so ResolveJSConfigFile can find it."],"exampleFix":"<!-- before -->\n{{ $js := $src | babel (dict \"config\" \"babel.confg.js\") }}\n<!-- after -->\n{{ $js := $src | babel }}  <!-- with babel.config.js in project root -->","handlingStrategy":"validation","validationCode":"# ensure config exists at project root before invoking\ntest -f babel.config.js || echo 'missing babel.config.js'","typeGuard":null,"tryCatchPattern":"{{ with try ($js | babel (dict \"config\" \"babel.config.js\")) }}{{ with .Err }}{{ errorf \"babel: %s\" . }}{{ end }}{{ end }}","preventionTips":["Place babel.config.js at the project root, or pass the correct `config` option path","Paths are relative to the project working directory — verify with an absolute path if unsure","Commit the babel config so CI has it; a local-only config is the classic CI failure"],"tags":["babel","configuration","file-not-found","hugo"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}