golang/go · info
unrecognized environment
Error message
unrecognized environment
What it means
On the js/wasm target, osinfo.Version() makes a best-effort attempt to detect the runtime by checking for a global 'process' object with a 'version' property (Node.js). If that is absent, the environment is unrecognized. This is purely for log readability (e.g. build.golang.org) — it is not a hard failure path.
Source
Thrown at src/cmd/internal/osinfo/os_js.go:24
package osinfo
import (
"fmt"
"syscall/js"
)
// Version returns the OS version name/number.
func Version() (string, error) {
// Version detection on Wasm varies depending on the underlying runtime
// (browser, node, etc), nor is there a standard via something like
// WASI (see https://go.dev/issue/31105). For now, attempt a few simple
// combinations for the convenience of reading logs at build.golang.org
// and local development. It's not a goal to recognize all environments.
if v, ok := node(); ok {
return "Node.js " + v, nil
}
return "", fmt.Errorf("unrecognized environment")
}
func node() (version string, ok bool) {
// Try the https://nodejs.org/api/process.html#processversion API.
p := js.Global().Get("process")
if p.IsUndefined() {
return "", false
}
v := p.Get("version")
if v.IsUndefined() {
return "", false
}
return v.String(), true
}
View on GitHub (pinned to b6b368adc5)
Solutions
- Treat the error as informational; version detection is explicitly best-effort.
- Run under Node.js if a version string is genuinely needed.
Defensive patterns
Strategy: fallback
Try / catch
// v, err := osinfo.Version()
// if err != nil {
// // js/wasm best-effort detection failed; degrade gracefully
// v = "unknown (js/wasm)"
// } Prevention
- Treat osinfo.Version on js/wasm as best-effort for logging only.
- Run under Node.js if a version string is genuinely required.
- Do not gate behavior on a non-empty version under js/wasm.
When it happens
Trigger: Calling osinfo.Version() in a js/wasm build running in a JS environment without 'process.version' — e.g. a plain browser, a minimal JS shell, or an older engine.
Common situations: Running a Go js/wasm binary in a browser-only context, or in a custom/embedded JS runtime that does not expose Node's process API.
Related errors
- unable to determine OS version: %w
- globalThis.crypto is not available, polyfill required (crypt
- globalThis.performance is not available, polyfill required (
- globalThis.TextEncoder is not available, polyfill required
- globalThis.TextDecoder is not available, polyfill required
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/fe3d577f86f1114c.
Report an issue: GitHub.