Node-RED Environment Variable Reader

1.0.2 · active · verified Sun Apr 19

This package provides a dedicated Node-RED node (`process-env`) for retrieving environment variables from the server process where Node-RED is executing. It serves as a fundamental utility for integrating Node-RED flows with their host environment, enabling external configuration without modifying the flow directly. The node, currently at stable version 1.0.2, simplifies accessing `process.env` values compared to using a generic Function node. Its release cadence is typically driven by bug fixes or minor compatibility updates. A key differentiator is its straightforward configuration within the Node-RED editor, allowing users to specify the environment variable key directly or infer it from incoming message properties (`payload` or `topic`), with a clear order of precedence. This makes it a go-to solution for parameterizing Node-RED applications.

Common errors

Warnings

Install

Imports

Quickstart

This Node-RED flow demonstrates reading an environment variable. First, ensure the environment variable `MY_ENV_VAR` is set in the Node-RED server's environment (e.g., `export MY_ENV_VAR='Hello from Env!'` before starting Node-RED). The Inject node triggers the flow. The 'Read MY_ENV_VAR' node (`process-env` type) is configured to look for a variable named `MY_ENV_VAR`. The Debug node displays the retrieved value (or `undefined` if not found) in the Node-RED debug sidebar.

[{"id":"e05f2e82f7169f4b","type":"inject","z":"0453347f311c6264","name":"Trigger","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":120,"y":80,"wires":[["715d31518f888f4c"]]},{"id":"715d31518f888f4c","type":"process-env","z":"0453347f311c6264","name":"Read MY_ENV_VAR","key":"MY_ENV_VAR","x":340,"y":80,"wires":[["ed27fb47184209c1"]]},{"id":"ed27fb47184209c1","type":"debug","z":"0453347f311c6264","name":"Debug Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":570,"y":80,"wires":[]}]

view raw JSON →