{"record":{"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/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/resource_transformers/babel/babel.go#L130-L166","documentation":"Thrown by the Babel transformer when options.Config is explicitly set by the user (via the babel options 'config' key) but the named file cannot be resolved against the project's JS config file system (BaseFs.ResolveJSConfigFile returns empty). Auto-discovered configs (babel.config.js/mjs/cjs) never trigger this; it fires only for a user-specified config path that is missing.","triggerScenarios":"Calling resources.Babel with an options map containing \"config\": \"./some/path/babel.config.js\" where that path does not exist under the project or asset filesystem, or passing a relative path that BaseFs.ResolveJSConfigFile cannot resolve to an absolute file.","commonSituations":"Renaming or deleting a custom babel config without updating the babel options in the template; pointing config at a path inside assets/ that has not been created; case-sensitivity mismatch on Linux for a config path copied from macOS/Windows.","solutions":["Verify the file referenced by options[\"config\"] exists; the error message echoes the exact path Hugo could not resolve.","Use an absolute path or place the config at the project/working-dir root so BaseFs.ResolveJSConfigFile can find it.","Drop the 'config' option entirely and let Hugo auto-discover babel.config.js / babel.config.mjs / babel.config.cjs."],"exampleFix":"// before\n{{ $js := resources.Get \"js/main.js\" | babel (dict \"config\" \"configs/babel.js\") }}\n\n// after\n{{ $js := resources.Get \"js/main.js\" | babel (dict \"config\" \"babel.config.js\") }}","handlingStrategy":"validation","validationCode":"// Validate the user-specified babel config path exists before invoking.\nif cfg, ok := opts[\"config\"]; ok {\n    p := filepath.Clean(fmt.Sprint(cfg))\n    if _, err := os.Stat(p); err != nil {\n        return fmt.Errorf(\"babel config %q not found\", p)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer auto-discovered babel.config.js over an explicit 'config' option.","Version-control your babel config alongside the templates that reference it.","On case-sensitive OSes, double-check exact filenames of custom config paths."],"tags":["babel","configuration","config-not-found","asset-pipeline"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}