# Support for \`process.env\` in JS runtime

**URL:** https://forum.heroiclabs.com/t/support-for-process-env-in-js-runtime/2907
**Category:** Runtime Framework
**Created:** [August 4, 2022, 12:36pm UTC](https://forum.heroiclabs.com/t/support-for-process-env-in-js-runtime/2907 "2022-08-04T12:36:51Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![MarcusRiemer](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/marcusriemer/32/1279_2.png) [@MarcusRiemer](https://forum.heroiclabs.com/u/MarcusRiemer)
#### Post date: [August 4, 2022, 12:36pm UTC](https://forum.heroiclabs.com/t/support-for-process-env-in-js-runtime/2907/1 "2022-08-04T12:36:51Z")

</div>

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](https://github.com/dop251/goja_nodejs/issues/32)) 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](https://github.com/dop251/goja_nodejs/pull/33)). 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?

---

<div class="post-metadata">

### Author: ![lugehorsam](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/lugehorsam/32/314_2.png) [@lugehorsam](https://forum.heroiclabs.com/u/lugehorsam)
#### Post date: [August 4, 2022, 1:44pm UTC](https://forum.heroiclabs.com/t/support-for-process-env-in-js-runtime/2907/2 "2022-08-04T13:44:35Z")

</div>

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.

Thanks,  
Luke

---

<div class="post-metadata">

### Author: ![formatCvt](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/formatcvt/32/1127_2.png) [@formatCvt](https://forum.heroiclabs.com/u/formatCvt)
#### Post date: [August 12, 2022, 9:20am UTC](https://forum.heroiclabs.com/t/support-for-process-env-in-js-runtime/2907/3 "2022-08-12T09:20:59Z")

</div>

You can use this [Nakama: Configuration | Heroic Labs Documentation](https://heroiclabs.com/docs/nakama/getting-started/configuration/#runtime.env)

---

<div class="post-metadata">

### Author: ![MarcusRiemer](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/marcusriemer/32/1279_2.png) [@MarcusRiemer](https://forum.heroiclabs.com/u/MarcusRiemer)
#### Post date: [August 12, 2022, 10:29am UTC](https://forum.heroiclabs.com/t/support-for-process-env-in-js-runtime/2907/4 "2022-08-12T10:29:53Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![formatCvt](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/formatcvt/32/1127_2.png) [@formatCvt](https://forum.heroiclabs.com/u/formatCvt)
#### Post date: [August 12, 2022, 11:45am UTC](https://forum.heroiclabs.com/t/support-for-process-env-in-js-runtime/2907/5 "2022-08-12T11:45:35Z")

</div>

Oh, my bad, you’re right

---

<div class="post-metadata">

### Author: ![MarcusRiemer](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/marcusriemer/32/1279_2.png) [@MarcusRiemer](https://forum.heroiclabs.com/u/MarcusRiemer)
#### Post date: [August 23, 2022, 2:24pm UTC](https://forum.heroiclabs.com/t/support-for-process-env-in-js-runtime/2907/6 "2022-08-23T14:24:24Z")

</div>

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](https://github.com/heroiclabs/nakama/pull/902)
