slimtoolkit/slim · error
sensor: artifact - getNuxtConfig - error getting buildDir =>
Error message
sensor: artifact - getNuxtConfig - error getting buildDir => %s
What it means
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.
Source
Thrown at pkg/app/sensor/artifact/artifact.go:3045
nuxt := nuxtDirs{
Build: nuxtDefaultBuildDir,
Dist: fmt.Sprintf("%s/%s", nuxtDefaultBuildDir, nuxtDefaultDistDir),
}
/*
todo: need more test apps to verify this part of the code
vm := otto.New()
vm.Run(dat)
if value, err := vm.Get(nuxtBuildDirKey); err == nil {
if v, err := value.ToString(); err == nil {
nuxt.Build = v
} else {
log.Debugf("saveArtifacts - using build default => %s", err.Error())
}
} else {
log.Debug("saveArtifacts - error reading nuxt.config.js file => ", err.Error())
return nil, fmt.Errorf("sensor: artifact - getNuxtConfig - error getting buildDir => %s", path)
}
if value, err := vm.Get(nuxtDistDirKey); err == nil {
if v, err := value.ToString(); err == nil {
nuxt.Dist = fmt.Sprintf("%s/%s", nuxt.Build, v)
} else {
log.Debugf("saveArtifacts - using dist default => %s", err.Error())
}
} else {
log.Debug("saveArtifacts - reading nuxt.config.js file => ", err.Error())
return nil, fmt.Errorf("sensor: artifact - getNuxtConfig - error getting distDir => %s", path)
}
*/
return &nuxt, nil
}
func isNuxtConfigFile(filePath string) bool {View on GitHub (pinned to 81940d17fa)
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.
Example fix
// before
return nil, fmt.Errorf("sensor: artifact - getNuxtConfig - error getting buildDir => %s", path)
// after
// fallback: regex the raw config when the VM cannot evaluate it
re := regexp.MustCompile(`build\s*:\s*{[^}]*dir\s*:\s*['"]([^'"]+)['"]`)
if m := re.FindStringSubmatch(string(dat)); m != nil {
nuxt.Build = m[1]
} Defensive patterns
Strategy: fallback
Try / catch
nuxt, err := getNuxtConfig(configPath)
if err != nil {
if strings.Contains(err.Error(), "error getting buildDir") {
log.Warnf("could not evaluate nuxt.config buildDir; using default %q", "'.nuxt'")
return useDefaultNuxtDirs(configPath)
}
return err
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- sensor: artifact - getNuxtConfig - error getting distDir =>
- invalid HTTP probe command: %s
- sensor: artifact - getNuxtConfig - error getting file => %s
- sensor: artifact - getNuxtConfig - error reading file => %s
AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31).
Data as JSON: /api/errors/666bb63d78582fb2.
Report an issue: GitHub.