# Exec node - Allow adding variables to the process environment

**URL:** <https://discourse.nodered.org/t/exec-node-allow-adding-variables-to-the-process-environment/90338>\
**Category:** Feature Requests\
**Created:** [22 August 2024 15:40 UTC](https://discourse.nodered.org/t/exec-node-allow-adding-variables-to-the-process-environment/90338 "2024-08-22T15:40:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nsain](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nsain/32/93758_2.png) [@nsain](https://discourse.nodered.org/u/nsain)\
**Post date:** [22 August 2024 15:40 UTC](https://discourse.nodered.org/t/exec-node-allow-adding-variables-to-the-process-environment/90338/1 "2024-08-22T15:40:29Z")

</div>

I've been using environment variables to store credentials in flows and groups and would like to easily pass them to a executed process without exposing them on the command line. Adding them to the process environment let me accomplish this.

Editing 90-exec.js I've naively inserted the following after line 143[1]  
`if (typeof msg?.env == "object") node.execOpt.env = msg.env;`

and after line 93[2]  
`if (typeof msg?.env == "object") opts.env = msg.env;`

to accomplish this. I'm not a developer but would be interested in adding this to the core node if the maintainers will take a PR. Currently this code naively changes the default behavior of the exec node so I may add an additional setting in the node configuration GUI to disable this behavior or select a different message object. If that would make merging this feature more feasible I am willing to add to the GUI.

Thanks for your consideration,  
Nathan

[1] [node-red/packages/node\_modules/@node-red/nodes/core/function/90-exec.js at a2430b772bd0800d3ebaf4fbe1396ca1fd5f23d6 · node-red/node-red · GitHub](https://github.com/node-red/node-red/blob/a2430b772bd0800d3ebaf4fbe1396ca1fd5f23d6/packages/node_modules/%40node-red/nodes/core/function/90-exec.js#L143)

[2] [node-red/packages/node\_modules/@node-red/nodes/core/function/90-exec.js at a2430b772bd0800d3ebaf4fbe1396ca1fd5f23d6 · node-red/node-red · GitHub](https://github.com/node-red/node-red/blob/a2430b772bd0800d3ebaf4fbe1396ca1fd5f23d6/packages/node_modules/%40node-red/nodes/core/function/90-exec.js#L93)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [21 October 2024 15:40 UTC](https://discourse.nodered.org/t/exec-node-allow-adding-variables-to-the-process-environment/90338/2 "2024-10-21T15:40:42Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
