This looks like a lot of info however look to the right for a navigation bar for easier reading.
Install Node-REDThe easiest way to install Node-RED is to use node’s package manager, npm. Installing it as a global module adds the command node-red
to your system path:
sudo npm install -g --unsafe-perm node-red
Note: you should not use npm 1.x
to install Node-RED. You can upgrade to the latest npm 2.x
version with the command: sudo npm install -g
npm@2.x
Note: sudo
is required if running as a non-root user on Linux/OS X. If running on Windows, you will need to run in a command shell as Administrator, without the sudo
command.
Note: During the install some errors may be reported by the node-gyp
command. These are typically non-fatal errors and are related to optional dependencies that require a compiler in order to build them. Node-RED will work without these optional dependencies, but you may find additional node modules that require the ability to compile native code. You can find out how to install the node-gyp
compiler dependencies here.
Once installed, you are ready to run Node-RED.
If you have installed Node-RED as a global npm package, you can use the node-red
command:
$ node-red
Welcome to Node-RED
===================
25 Feb 22:51:09 - [info] Node-RED version: v0.14.6
25 Feb 22:51:09 - [info] Node.js version: v4.6.0
25 Feb 22:51:09 - [info] Loading palette nodes
25 Feb 22:51:10 - [warn] ------------------------------------------
25 Feb 22:51:10 - [warn] [rpi-gpio] Info : Ignoring Raspberry Pi specific node
25 Feb 22:51:10 - [warn] ------------------------------------------
25 Feb 22:51:10 - [info] Settings file : /home/nol/.node-red/settings.js
25 Feb 22:51:10 - [info] User Directory : /home/nol/.node-red
25 Feb 22:51:10 - [info] Server now running at http://127.0.0.1:1880/
25 Feb 22:51:10 - [info] Creating new flows file : flows_noltop.json
25 Feb 22:51:10 - [info] Starting flows
25 Feb 22:51:10 - [info] Started flows
You can then access the Node-RED editor at http://localhost:1880.
There are specific instructions available for certain hardware platforms:
NextYou can now create your first flow.
Running from a local install - Linux & Mac OS XThe node-red
command can still be accessed even if Node-RED hasn’t been installed as a global npm package.
If you have npm installed Node-RED, this script will be node_modules/node-red/bin/node-red
, relative to the directory you ran npm install
in. If you have installed from a release zip file, the script will be node-red-X.Y.Z/bin/node-red
, relative to the directory you extracted the zip into.
First make the node-red
start script executable:
chmod +x <node-red-install-directory>/bin/node-red
Then you can start Node-RED with:
<node-red-install-directory>/bin/node-red
Running from a local install - WindowsOn Windows, run the following command from the same directory you ran npm install
in, or that you extracted the release zip file:
node node_modules/node-red/red.js
Command-line usageUsage: node-red [-v] [-?] [--settings settings.js] [--userDir DIR] [flows.json]
Options:
-s, --settings FILE use specified settings file
-u, --userDir DIR use specified user directory
-v enable verbose output
-?, --help show usage
Storing user dataBy default, Node-RED stores your data in the directory $HOME/.node-red
. For backwards compatibility reasons, if Node-RED detects user data in its install directory, it will use that instead. The upgradingdocumentation includes a section on migrating your data out of the Node-RED install directory.
To override what directory to use, the --userDir
command-line option can be used.
There are occasions when it is necessary to pass arguments to the underlying node.js process. For example, when running on devices like the Raspberry Pi or BeagleBone Black that have a constrained amount of memory.
To do this, you must use the node-red-pi
start script in place of node-red
. Note: this script is not available on Windows.
Alternatively, if are running Node-RED using the node
command, you must provide arguments for the node process before specifying red.js
and the arguments you want passed to Node-RED itself.
The following two commands show these two approaches:
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/
Starting Node-RED on bootThere are many methods of starting, stopping and monitoring applications at boot time. Raspberry Pi users are strongly recommended to follow these instructions.
The guide below sets out what we believe to be the most straight-forward for the majority of users. For Windows, PM2 does not autorun as a service - you may prefer the NSSM option below.
Using PM2PM2 is a process manager for Node.js. It makes it easy to run applications on boot and ensure they are restarted if necessary.
Note: PM2 is released under GNU-AGPL-3.0 license - please check the terms of the license before deploying.
1. Install PM2sudo npm install -g pm2
Note:
sudo
is required if running as a non-root user on Linux/OS X. If running on Windows, you will need to run in a command shell as Administrator, without the
sudo
command.If running on Windows, you should also ensure
tail.exe
is on your path, as described here.
2. Determine the exact location of the node-red command.If you have done a global install of node-red, then on Linux/OS X the node-red
command will probably be either: /usr/bin/node-red
or /usr/local/bin/node-red
. The command which node-red
can be used to confirm the location.
If you have done a local install, it will be node_modules/node-red/bin/node-red
, relative to where you ran npm install
from.
The following command tells PM2 to run Node-RED, assuming /usr/bin/node-red
as the location of the node-red
command.
The --
argument must appear before any arguments you want to pass to node-red.
pm2 start /usr/bin/node-red -- -v
Note: if you are running on a device like the Raspberry Pi or BeagleBone Black that have a constrained amount of memory, you must pass an additional argument:pm2 start /usr/bin/node-red --node-args="--max-old-space-size=128" -- -vNote: if you want to run as the root user, you must use the `--userDir` option to specify where Node-RED should store your data.
This will start Node-RED in the background. You can view information about the process and access the log output using the commands:
pm2 info node-red
pm2 logs node-red
More information about managing processes under PM2 is available here.
4. Tell PM2 to run on bootPM2 is able to generate and configure a startup script suitable for the platform it is being run on.
Run these commands and follow the instructions it provides:
pm2 save
pm2 startup
for newer Linux systems that use systemd use
pm2 startup systemd
Temporary Note: There's an open issue on PM2 on GitHub which highlights an issue that has been introduced recently. Linux users need to manually edit the generated `/etc/init.d/pm2-init.sh` file and replaceexport PM2_HOME="/root/.pm2"to point at the correct directory, which would be like:export PM2_HOME="/home/{youruser}/.pm2"
5. RebootFinally, reboot and check everything starts as expected.
Alternative optionsThere are many alternative approaches. The following are some of those created by members of the community.
- A systemd script (used by the Pi pre-install) by @NodeRED (linux)
- A systemd script by Belphemur (linux)
- An init.d script by dceejay (linux)
- An init.d script by Belphemur (linux)
- A Launchd script by natcl (OS X)
- Running as a Windows service using NSSM by dceejay
- Running as Windows/OS X service by Ben Hardill
Node-RED comes with a core set of useful nodes, but there are a growing number of additional nodes available for install from both the Node-RED project as well as the wider community.
You can search for available nodes in the Node-RED library or on the npm repository.
Using the EditorFrom version 0.15 you can install nodes directly using the editor. To to this select Manage Palette
from the menu (top right), and then select the install
tab in the palette. You can now search for new nodes to install, and enable and disable existing nodes.
To install an npm-packaged node, you can either install it locally within your user data directory (by default, $HOME/.node-red
):
cd $HOME/.node-red
npm install <npm-package-name>
or globally alongside Node-RED:
sudo npm install -g <npm-package-name>
You will need to restart Node-RED for it to pick-up the new nodes.
Installing individual node filesIt is also possible to install nodes by copying their .js
and .html
files into a nodes
directory within your user data directory. If these nodes have any npm dependencies, they must be also be installed within the user data directory. This is only really recommended for development purposes.
Node-RED provides a browser-based flow editor that makes it easy to wire together flows using the wide range of nodes in the palette. Flows can be then deployed to the runtime in a single-click.
JavaScript functions can be created within the editor using a rich text editor.
A built-in library allows you to save useful functions, templates or flows for re-use.
Built on Node.jsThe light-weight runtime is built on Node.js, taking full advantage of its event-driven, non-blocking model. This makes it ideal to run at the edge of the network on low-cost hardware such as the Raspberry Pi as well as in the cloud.
With over 225,000 modules in Node's package repository, it is easy to extend the range of palette nodes to add new capabilities.
The flows created in Node-RED are stored using JSON which can be easily imported and exported for sharing with others.
An online flow library allows you to share your best flows with the world.
Get StartedNode-RED is built on Node.js, taking full advantage of its event-driven, non-blocking model. This makes it ideal to run at the edge of the network on low-cost hardware such as the Raspberry Pi as well as in the cloud.
Comments
Please log in or sign up to comment.