You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
20220708 Node-RED - master branch - PR 1 of 2 - part 2
Fixes `nodered_list_installed_nodes.sh`. Now relies on `npm` running
inside the container to discover what's installed where.
Documentation describing use of `/data` on `npm` calls turns out to be
ineffective. The solution is to set the working directory on the
`docker exec` call.
Following on from a discussion on Discord
[starting here](https://discord.com/channels/638610460567928832/638610461109256194/994818372439113838),
it was obviously confusing for the documentation to be discussing
"nodes" when `npm` can be used to install a variety of components.
Documentation adjusted to clarify this.
Signed-off-by: Phill Kelley <[email protected]>
Copy file name to clipboardExpand all lines: docs/Containers/Node-RED.md
+77-85Lines changed: 77 additions & 85 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,7 +54,7 @@ You choose add-on nodes from a supplementary menu. We recommend accepting the de
54
54
Key points:
55
55
56
56
* Under new menu, you must press the right arrow to access the supplementary menu. Under old menu, the list of add-on nodes is displayed automatically.
57
-
* Do not be concerned if you can't find an add-on node you need in the list. You can also add nodes via Manage Palette once Node-RED is running. See [node management](#nodeManagement).
57
+
* Do not be concerned if you can't find an add-on node you need in the list. You can also add nodes via Manage Palette once Node-RED is running. See [component management](#componentManagement).
58
58
59
59
Choosing add-on nodes in the menu causes the *Dockerfile* to be created.
60
60
@@ -256,7 +256,7 @@ To communicate with your Raspberry Pi's GPIO you need to do the following:
2. Install the `node-red-node-pi-gpiod` node. See [node management](#nodeManagement). It allows you to connect to multiple Pis from the same Node-RED service.
259
+
2. Install the `node-red-node-pi-gpiod` node. See [component management](#componentManagement). It allows you to connect to multiple Pis from the same Node-RED service.
260
260
3. Make sure that the `pigpdiod` daemon is running. The recommended method is listed [here](https://github.com/node-red/node-red-nodes/tree/master/hardware/pigpiod). In essence, you need to:
261
261
262
262
- Use `sudo` to edit `/etc/rc.local`;
@@ -991,71 +991,78 @@ For example, suppose you wanted to pin to Node-RED version 2.2.2 with `node.js`
991
991
992
992
Changing a pinned version and rebuilding *may* result in a new *base* image being downloaded from *DockerHub*.
993
993
994
-
## Node management { #nodeManagement }
994
+
## Component management { #componentManagement }
995
995
996
-
### Installing nodes { #addNodes }
996
+
### via Dockerfile { #viaDockerfile }
997
997
998
-
You can install nodes by:
998
+
You can install components by adjusting the Node-RED *Dockerfile*. This can be done by:
999
999
1000
-
1. Adjusting the Node-RED *Dockerfile*. This can be done by:
1000
+
* Running the IOTstack menu and changing the selected Node-RED nodes; or
1001
+
* Editing your Node-RED *Dockerfile* using a text editor.
1001
1002
1002
-
* Running the IOTstack menu and changing the selected Node-RED nodes; or
1003
-
* Editing your Node-RED *Dockerfile* using a text editor.
1003
+
Using the IOTstack menu limits your choice of components to those presented in the menu. Editing the *Dockerfile* with a text editor is more flexible but carries the risk that your changes could be lost if you subsequently use the menu method.
1004
1004
1005
-
Using the IOTstack menu limits your choice of nodes to those presented in the menu. Editing the *Dockerfile* with a text editor is more flexible but carries the risk that your changes could be lost if you subsequently use the menu method.
1005
+
To apply changes made to your *Dockerfile*, run the [re-building the local Node-RED image](#rebuildNodeRed) commands.
1006
1006
1007
-
To apply changes made to your *Dockerfile*, run the [re-building the local Node-RED image](#rebuildNodeRed) commands.
1007
+
### via Manage Palette { #viaDockerfile }
1008
1008
1009
-
2. Adding, removing or updating nodes in Manage Palette. Node-RED will remind you to restart Node-RED and that is something you have to do by hand:
1009
+
You can add, remove or update components in Manage Palette. Node-RED will remind you to restart Node-RED and that is something you have to do by hand:
1010
1010
1011
-
``` console
1012
-
$ cd ~/IOTstack
1013
-
$ docker-compose restart nodered
1014
-
```
1011
+
``` console
1012
+
$ cd ~/IOTstack
1013
+
$ docker-compose restart nodered
1014
+
```
1015
1015
1016
-
Note:
1016
+
Note:
1017
1017
1018
-
* Some users have reported misbehaviour from Node-RED if they do too many iterations of:
1018
+
* Some users have reported misbehaviour from Node-RED if they do too many iterations of:
1019
+
1020
+
- make a change in Manage Palette
1021
+
- restart Node-RED
1019
1022
1020
-
``` console
1021
-
[make a single change in Manage Palette]
1022
-
$ docker-compose restart nodered
1023
+
It is better to make **all** the changes you intend to make, and only *then* restart Node-RED.
1023
1024
1024
-
[make a single change in Manage Palette]
1025
-
$ docker-compose restart nodered
1026
-
1027
-
…
1028
-
```
1025
+
### via `npm` { #viaNPM }
1029
1026
1030
-
It is better to:
1027
+
You can also run `npm` inside the container to install any component that could be installed by `npm` in a non-container environment. This is the basic syntax:
* You **must** put the `/data` onto the end of the `npm install` command. Any formula you find on the web will not include this. You have to remember to do it yourself!
1051
-
* See also the note above about restarting too frequently.
1052
-
* You can use this approach if you need to force the installation of a specific version (which you don't appear to be able to do in Manage Palette). For example, to install version 4.0.0 of the "moment" node:
1053
+
* You **must** include `-w /data` on each command. Any formula you find on the web will not include this. You have to remember to do it yourself!
1054
+
* Many web examples include the `--save` flag on the `npm` command. That flag is not needed (it is ignored because the behaviour it used to control has been the default since NPM version 5. Node-RED containers have been using NPM version 6 for some time.
1055
+
* See also the note above about restarting too frequently.
1056
+
* You can use this approach if you need to force the installation of a specific version (which you don't appear to be able to do in Manage Palette). For example, to install version 4.0.0 of the "moment" node:
There is no real difference between the methods. Some nodes (eg "node-red-contrib-generic-ble" and "node-red-node-sqlite") **must** be installed by *Dockerfile* but the only way of finding out if a node **must** be installed via *Dockerfile* is to try Manage Palette and find that it doesn't work.
1065
+
In terms of outcome, there is no real difference between the various methods. However, some nodes (eg "node-red-contrib-generic-ble" and "node-red-node-sqlite") **must** be installed by *Dockerfile*. The only way of finding out if a component **must** be installed via *Dockerfile* is to try Manage Palette and find that it doesn't work.
1059
1066
1060
1067
Aside from the exception cases that require *Dockerfile* or where you need to force a specific version, it is quicker to install nodes via Manage Palette and applying updates is a bit easier too. But it's really up to you.
1061
1068
@@ -1066,62 +1073,44 @@ If you're wondering about "backup", nodes installed via:
1066
1073
1067
1074
Basically, if you're running IOTstack backups then your add-on nodes will be backed-up.
1068
1075
1069
-
### Node precedence { #nodePrecedence }
1076
+
### Component precedence { #componentPrecedence }
1070
1077
1071
-
Add-on nodes that are installed via *Dockerfile* wind up at the **internal** path:
1078
+
Components that are installed via *Dockerfile* wind up at the **internal** path:
1072
1079
1073
1080
```
1074
-
/usr/src/node-red/node_modules
1081
+
/usr/src/node-red
1075
1082
```
1076
1083
1077
-
Add-on nodes installed via Manage Palette wind up at the **external** path:
1084
+
Components installed via Manage Palette or `docker exec -w /data` wind up at the **internal** path:
1078
1085
1079
1086
```
1080
-
~/IOTstack/volumes/nodered/data/node_modules
1081
-
```
1082
-
1083
-
The *Compose* file volumes mapping:
1084
-
1085
-
``` yaml
1086
-
./volumes/nodered/data:/data
1087
+
/data
1087
1088
```
1088
1089
1089
-
implies that add-on nodes installed via Manage Palette are made available to Node-RED at the **internal** path:
1090
+
which is the same as the **external** path:
1090
1091
1091
1092
```
1092
-
/data/node_modules
1093
+
~/IOTstack/volumes/nodered/data
1093
1094
```
1094
1095
1095
-
Because there are two places, this invites the question of what happens if a given node is installed in both? The answer is that add-ons installed at:
1096
+
Because there are two places, this invites the question of what happens if a given component is installed in both? The answer is that components installed in `/data` take precedence.
1096
1097
1097
-
```
1098
-
/data/node_modules
1099
-
```
1100
-
1101
-
take precedence over those installed at:
1102
-
1103
-
```
1104
-
/usr/src/node-red/node_modules
1105
-
```
1106
-
1107
-
Or, to put it more simply: in any contest, Manage Palette prevails over *Dockerfile*.
1098
+
Or, to put it more simply: in any contest between methods, *Dockerfile* comes last.
Sometimes, even when you are 100% certain that **you** didn't do it, an add-on node will turn up in both places. There is probably some logical reason for this but I don't know what it is.
1112
-
1113
-
The problem this creates is that a later version of an add-on node installed via *Dockerfile* will be blocked by the presence of an older version of that node in:
1102
+
Sometimes, even when you are 100% certain that **you** didn't do it, a component will turn up in both places. There is probably some logical reason for this but I don't know what it is.
1114
1103
1115
-
```
1116
-
~/IOTstack/volumes/nodered/data/node_modules
1117
-
```
1104
+
The problem this creates is that a later version of a component installed via *Dockerfile* will be blocked by the presence of an older version of that component installed by a different method.
1118
1105
1119
1106
The `nodered_list_installed_nodes.sh` script helps discover when this situation exists. For example:
0 commit comments