Support for `process.env` in JS runtime

Hello there and thanks for providing this wonderful framework.

I am currently in the process of making my turn based Typescript backend Nakama / goja compatible and stumbled over a recurring annoyance: Some libraries test for process.env to decide which version to load and without extra care this simply crashes during startup. I tried workarounds like rollup plugins, changed my Typescript imports and ultimately decided to tackle the problem at the root. So I got in contact with the Goja devs (Support for `process.env`? · Issue #32 · dop251/goja_nodejs · GitHub) and provided a PR to hack in support that would stop process.env expressions from crashing (Minimal implementation to provide `process.env` by MarcusRiemer · Pull Request #33 · dop251/goja_nodejs · GitHub). At the most basic level required for my use case this was refreshingly simple.

Now once this got into goja I would obviously like to incorporate this into Nakama. This would mean to add a dependency to goja_nodejs in (probably) runtime_javascript_init.go. Would you welcome such a PR?

1 Like

Hey @MarcusRiemer thank you for going through that process in order to make Goja and Nakama a better product. We would absolutely welcome that PR but may have some public discussion on the PR. Please tag @lugehorsam when you open it so I catch it.


You can use this Nakama: Configuration | Heroic Labs Documentation

From what I understand these variables are not exposed in the “typical” node.js fashion using the global process.env object. I am not having an issue with code that I am specifically creating for Nakama, my issue is with third party code that assumes node.js conventions.

1 Like

Oh, my bad, you’re right

PR is now available: Ensure that JavaScript code accessing `process.env` doesn't immediatly crash the VM by MarcusRiemer · Pull Request #902 · heroiclabs/nakama · GitHub

1 Like