diff --git a/compiler/natives/src/runtime/runtime.go b/compiler/natives/src/runtime/runtime.go index ebd85d84e..bcea9ad8e 100644 --- a/compiler/natives/src/runtime/runtime.go +++ b/compiler/natives/src/runtime/runtime.go @@ -80,7 +80,7 @@ func init() { func GOROOT() string { process := js.Global.Get("process") - if process == js.Undefined { + if process == js.Undefined || process.Get("env") == js.Undefined { return "/" } if v := process.Get("env").Get("GOPHERJS_GOROOT"); v != js.Undefined && v.String() != "" { diff --git a/compiler/natives/src/syscall/syscall_js_wasm.go b/compiler/natives/src/syscall/syscall_js_wasm.go index f4039a420..5bcbdeed4 100644 --- a/compiler/natives/src/syscall/syscall_js_wasm.go +++ b/compiler/natives/src/syscall/syscall_js_wasm.go @@ -10,6 +10,9 @@ func runtime_envs() []string { return nil } jsEnv := process.Get("env") + if jsEnv.IsUndefined() { + return nil + } envkeys := js.Global().Get("Object").Call("keys", jsEnv) envs := make([]string, envkeys.Length()) for i := 0; i < envkeys.Length(); i++ {