Skip to content

Commit ae80bd3

Browse files
authored
Update environment-variables.md
1 parent f3e29b1 commit ae80bd3

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

docs/user-guide/environment-variables.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ function:
5959
```javascript
6060
let foo = env.get("FOO");
6161
```
62-
62+
### Template node
63+
Beginning with [version 3.0](https://nodered.org/blog/2022/07/14/version-3-0-released#environment-variables-in-the-template-node
64+
), the `template` node can access environment variables using the syntax:
65+
```
66+
My favourite colour is {{env.COLOUR}}
67+
```
6368

6469
### Subflow Instance properties
6570

@@ -71,3 +76,21 @@ For example, given a REST API that provides access to different types of record,
7176
a subflow could be created to access the API and handle the response, using an
7277
environment variable to identify which type of record should be accessed. Individual
7378
instances of the Subflow can then be customised for those particular types.
79+
80+
### Flow/Group level environment variables
81+
82+
Since [version 2.1](https://nodered.org/blog/2021/10/21/version-2-1-released#flowgroup-level-environment-variables), environment variables can be set at the flow or group level. This is done in the appropriate tab in the edit dialog for the flow or group.
83+
84+
### Raspberry Pi OS considerations
85+
Users who have installed Node-RED on a Raspberry Pi using the provided [script](https://nodered.org/docs/getting-started/raspberrypi) and who run it as a service on booting or by using the `node-red-start` command should be aware that their flows will not have access to environment variables that are defined only in the calling process. In this case, environment variables can be defined in the settings file by statements of the form
86+
````
87+
process.env.FOO= 'World';
88+
````
89+
placed outside the `module.exports` section. Alternatively, variables can be defined as part of the `systemd` service by placing statements of the form
90+
```
91+
ENV_VAR='foobar'
92+
````
93+
in a file named `environment` in the Node-RED user directory, `~/.node-red`.
94+
95+
96+

0 commit comments

Comments
 (0)