{"record":{"id":"666bb63d78582fb2","repo":"slimtoolkit/slim","slug":"sensor-artifact-getnuxtconfig-error-getting-b","errorCode":null,"errorMessage":"sensor: artifact - getNuxtConfig - error getting buildDir => %s","messagePattern":"sensor: artifact - getNuxtConfig - error getting buildDir => (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/sensor/artifact/artifact.go","lineNumber":3045,"sourceCode":"\tnuxt := nuxtDirs{\n\t\tBuild: nuxtDefaultBuildDir,\n\t\tDist:  fmt.Sprintf(\"%s/%s\", nuxtDefaultBuildDir, nuxtDefaultDistDir),\n\t}\n\n\t/*\n\t\ttodo: need more test apps to verify this part of the code\n\t\tvm := otto.New()\n\t\tvm.Run(dat)\n\n\t\tif value, err := vm.Get(nuxtBuildDirKey); err == nil {\n\t\t\tif v, err := value.ToString(); err == nil {\n\t\t\t\tnuxt.Build = v\n\t\t\t} else {\n\t\t\t\tlog.Debugf(\"saveArtifacts - using build default => %s\", err.Error())\n\t\t\t}\n\t\t} else {\n\t\t\tlog.Debug(\"saveArtifacts - error reading nuxt.config.js file => \", err.Error())\n\t\t\treturn nil, fmt.Errorf(\"sensor: artifact - getNuxtConfig - error getting buildDir => %s\", path)\n\t\t}\n\n\t\tif value, err := vm.Get(nuxtDistDirKey); err == nil {\n\t\t\tif v, err := value.ToString(); err == nil {\n\t\t\t\tnuxt.Dist = fmt.Sprintf(\"%s/%s\", nuxt.Build, v)\n\t\t\t} else {\n\t\t\t\tlog.Debugf(\"saveArtifacts - using dist default => %s\", err.Error())\n\t\t\t}\n\t\t} else {\n\t\t\tlog.Debug(\"saveArtifacts - reading nuxt.config.js file => \", err.Error())\n\t\t\treturn nil, fmt.Errorf(\"sensor: artifact - getNuxtConfig - error getting distDir => %s\", path)\n\t\t}\n\t*/\n\n\treturn &nuxt, nil\n}\n\nfunc isNuxtConfigFile(filePath string) bool {","sourceCodeStart":3027,"sourceCodeEnd":3063,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/sensor/artifact/artifact.go#L3027-L3063","documentation":"Inside getNuxtConfig, the nuxt.config file is evaluated with a JS VM (otto) to extract build.dir. If the VM lookup of the build directory key fails, the function returns this error naming the config path. The config was found and readable, but its contents could not be evaluated or did not expose the expected buildDir property.","triggerScenarios":"The otto VM fails evaluating nuxt.config.js (modern syntax otto cannot parse, e.g. ES modules/TypeScript/imports) or vm.Get(buildDirKey) errors while extracting the buildDir value.","commonSituations":"Nuxt config written in TypeScript or using ESM import syntax unsupported by the embedded JS engine; config using functions/dynamic values the VM cannot execute; newer Nuxt versions changing config structure.","solutions":["Check the debug log ('error reading nuxt.config.js file') for the VM's parse/eval error.","Ensure the config uses plain CommonJS syntax the embedded VM can parse (no TS annotations, no import statements).","Fall back to regex extraction of build.dir from the raw config text when VM evaluation fails.","Upgrade the sensor so its JS engine supports the config syntax in use."],"exampleFix":"// before\nreturn nil, fmt.Errorf(\"sensor: artifact - getNuxtConfig - error getting buildDir => %s\", path)\n// after\n// fallback: regex the raw config when the VM cannot evaluate it\nre := regexp.MustCompile(`build\\s*:\\s*{[^}]*dir\\s*:\\s*['\"]([^'\"]+)['\"]`)\nif m := re.FindStringSubmatch(string(dat)); m != nil {\n    nuxt.Build = m[1]\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"nuxt, err := getNuxtConfig(configPath)\nif err != nil {\n    if strings.Contains(err.Error(), \"error getting buildDir\") {\n        log.Warnf(\"could not evaluate nuxt.config buildDir; using default %q\", \"'.nuxt'\")\n        return useDefaultNuxtDirs(configPath)\n    }\n    return err\n}","preventionTips":["Keep nuxt.config in plain CommonJS that older JS engines can parse","Avoid TypeScript/ESM syntax in the config when tooling must evaluate it","Prefer static string values for build.dir over computed expressions"],"tags":["nuxt","javascript","vm-evaluation","config-parsing"],"backgroundTag":"config-parse-failed","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}