necessary conditions
To install Node-RED locally, you need a supported version of Node.js.
Install Node-RED using npm
To install Node-RED you can use the command included with npmnode.js:
sudo npm install -g –unsafe-perm node-red
If you are using Windows, do not sudo.
This command installs Node-RED and its dependencies as global modules.
You can confirm that it was successful if the command output ends up similar to the following:
node-red@1.1.0
added 332 packages from 341 contributors in 18.494s
found 0 vulnerabilities
Install Node-RED using npm
To run it in Docker in its simplest form, just run:
docker run -it -p 1880:1880 –name mynodered nodered/node-red
For more details, see Node-RED’s docker guide.
Install using snap
If your operating system supports Snap, you can install Node-RED:
sudo snap install node-red
When installed as a Snap package, it will run in a secure container that does not have access to some extra facilities you may need to use, such as:
· Access main system storage. Only the local home directory can be read/written.
· gcc – any binary components needed to compile node for installation
· git – required if you want to use project features
· Direct access to gpio hardware
· Access any external commands that your flow wants to use with the Exec node (for example).
· If you need access to system hardware or add nodes that require compilation, we recommend using a full installation of Node-RED rather than using snaps.
Get started with Node-RED
Once installed as a global module, you can start Node-RED in the terminal using the node-red command. You can stop Node-RED using Ctrl-C or closing the terminal window.
$node-red
Welcome to Node-RED====================
30 Jun 23:43:39 – [info] Node-RED version: v1.3.5
30 Jun 23:43:39 – [info] Node.jsversion: v14.7.2
30 Jun 23:43:39 – [info] Darwin 19.6.0 x64 LE
30 Jun 23:43:39 – [info] Loading palette nodes
30 Jun 23:43:44 – [warn] rpi-gpio : Raspberry Pi specific node set inactive
30 Jun 23:43:44 – [info] Settings file: /Users/nol/.node-red/settings.js
30 Jun 23:43:44 – [info] HTTP Static: /Users/nol/node-red/web
30 Jun 23:43:44 – [info] Context store: ‘default’ [module=localfilesystem]
30 Jun 23:43:44 – [info] User directory : /Users/nol/.node-red
30 Jun 23:43:44 – [warn] Projects disabled : set editorTheme.projects.enabled=true to enable
30 Jun 23:43:44 – [info] Creating new flows file : flows_noltop.json
30 Jun 23:43:44 – [info] Starting flows
30 Jun 23:43:44 – [info] Started flows
30 Jun 23:43:44 – [info] Server now running at http://127.0.0.1:1880/red/
You can then access the Node-RED editor by pointing your browser to http://localhost:1880.
The log output provides you with various information:
· Node-RED and Node.js versions
· Any errors encountered while trying to load the palette node
· The location of your settings files and user directories
· The name of the stream file it is using.
Node-REDflows_
Command line usage
Node-RED You can start node-red using the command. This command can take various parameters:
node-red [-v] [-?] [–settings settings.js] [–userDir DIR]
[–port PORT] [–title TITLE] [–safe] [flows.json|projectName]
[-DX=Y|@file]
Options | describe |
-p,–port PORT | Set the TCP port the runtime listens on. Default: 1880 |
–safe | Start Node-RED without starting a stream. This allows you to open the stream in the editor and make changes without the stream running. When you deploy your changes, the process starts. |
-s,–settings FILE | Set the settings file to use. Default: settings.js in userDir |
–titleTITL | Set process window title |
-u,–userDir DIR | Set the user directory to use. Default: ~/.node-red |
-v | Enable verbose output |
-DX=Y|@file | Override individual settings |
-?,–help | Show command line usage help and exit |
flows.json|projectName | This will set the flow file you want to use if the project feature is not enabled. If the Projects feature is enabled, this determines which project should be started. |
Node-REDflows_
Override individual settings
Starting from Node-RED 1.1.0
-D You can override individual settings on the command line using the (or –define) option.
For example, to change the logging level, you can use:
-D logging.console.level=trace
You can also provide custom settings as a file:
-D @./custom-settings.txt
The file should contain a list of settings to override:
logging.console.level=trace
logging.console.audit=true
Pass parameters to the underlying Node.js process
Sometimes it is necessary to pass parameters to the underlying Node.js process. For example, when running on a device with limited memory, such as a Raspberry Pi or BeagleBone Black.
To do this, you must use the node-red-pi startup script instead of node-red. Note: This script is not available on Windows.
Alternatively, if you are using the node command to run Node-RED, you must provide arguments to the node process before specifying red.js as well as the arguments to be passed to Node-RED itself.
The following two commands show both methods:
node-red-pi –max-old-space-size=128 –userDir /home/user/node-red-data/
node –max-old-space-size=128 red.js –userDir /home/user/node-red-data/
Upgrade Node-RED
If you have installed Node-RED as a global npm package, you can upgrade to the latest version using the following command:
sudo npm install -g –unsafe-perm node-red
If you are using Windows, do not sudo.