Running Node-RED locally : Node-RED (2024)

Running Node-RED locally : Node-RED (1)Running Node-RED locally : Node-RED (2)Running Node-RED locally : Node-RED (3)

If you are on a Raspberry Pi or any Debian-based operating system, includingUbuntu and Diet-Pi, you can use the Pi install script available here.

Running Node-RED locally : Node-RED (4)Running Node-RED locally : Node-RED (5)Running Node-RED locally : Node-RED (6)

If you are on an RPM-based operating system, includingRedHat, Fedora and CentOS, you can use the RPM install script available here.

Running Node-RED locally : Node-RED (7)

If you are using Windows, detailed instructions for installing Node-RED can be found here.

Prerequisites

To install Node-RED locally you will need a supported version of Node.js.

Installing with npm

To install Node-RED you can use the npm command that comes with node.js:

sudo npm install -g --unsafe-perm node-red

If you are using Windows, do not start the command with sudo.

That command will install Node-RED as a global module along with its dependencies.

You can confirm it has succeeded if the end of the command output looks similar to:

+ node-red@1.1.0added 332 packages from 341 contributors in 18.494sfound 0 vulnerabilities

Installing with docker

To run in Docker in its simplest form just run:

docker run -it -p 1880:1880 --name mynodered nodered/node-red

For more detailed information see our docker guide.

Installing with snap

If your OS supports Snap you can installNode-RED with:

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 that may be needed for you to use, such as:

  • access to main system storage. Can only read/write to local home directories.
  • gcc - needed to compile any binary components of nodes you want to install
  • git - needed if you want to use the Projects feature
  • direct access to gpio hardware
  • access to any external commands your flows want to use with the Exec node (for example).

If you need access to system hardware or to add nodes that require compilation then we recommend using a full install of Node-RED and not using the snap.

Running

Once installed as a global module you can use the node-red command to startNode-RED in your terminal. You can use Ctrl-C or close the terminal windowto stop Node-RED.

$ node-redWelcome to Node-RED===================30 Jun 23:43:39 - [info] Node-RED version: v1.3.530 Jun 23:43:39 - [info] Node.js version: v14.7.230 Jun 23:43:39 - [info] Darwin 19.6.0 x64 LE30 Jun 23:43:39 - [info] Loading palette nodes30 Jun 23:43:44 - [warn] rpi-gpio : Raspberry Pi specific node set inactive30 Jun 23:43:44 - [info] Settings file : /Users/nol/.node-red/settings.js30 Jun 23:43:44 - [info] HTTP Static : /Users/nol/node-red/web30 Jun 23:43:44 - [info] Context store : 'default' [module=localfilesystem]30 Jun 23:43:44 - [info] User directory : /Users/nol/.node-red30 Jun 23:43:44 - [warn] Projects disabled : set editorTheme.projects.enabled=true to enable30 Jun 23:43:44 - [info] Creating new flows file : flows_noltop.json30 Jun 23:43:44 - [info] Starting flows30 Jun 23:43:44 - [info] Started flows30 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 at http://localhost:1880.

The log output provides you various pieces of information:

  • The versions of Node-RED and Node.js
  • Any errors hit when it tried to load the palette nodes
  • The location of your Settings file and User Directory
  • The name of the flows file it is using.

Node-RED uses flows_<hostname>.json as the default flows file. You can changethis by providing the flow file name as argument to the node-red command.

Command-line Usage

Node-RED can be started using the command node-red. This command can takevarious arguments:

node-red [-v] [-?] [--settings settings.js] [--userDir DIR] [--port PORT] [--title TITLE] [--safe] [flows.json|projectName] [-D X=Y|@file]
Option Description
-p, --port PORT Sets the TCP port the runtime listens on. Default: 1880
--safe Starts Node-RED without starting the flows. This allows you to open the flows in the editor and make changes without the flows running. When you deploy your changes, the flows are then started.
-s, --settings FILE Sets the settings file to use. Default: settings.js in userDir
--title TITLE Set process window title
-u, --userDir DIR Sets the user directory to use. Default: ~/.node-red
-v Enables verbose output
-D X=Y|@file Override individual settings
-?, --help Shows command-line usage help and exits
flows.json|projectName If the Projects feature is not enabled, this sets the flow file you want to work with. If the Projects feature is enabled, this identifies which project should be started.

Node-RED uses flows_<hostname>.json as the default flows file. If the computeryou are running on may change its hostname, then you should ensure you provide astatic file name; either as a command-line argument or using the flowsFile optionin your settings file.

Override individual settings

Since Node-RED 1.1.0

You can override individual settings on the command-line using the -D (or --define)option.

For example, to change the logging level you can use:

-D logging.console.level=trace

You can also provide the custom settings as a file:

-D @./custom-settings.txt

The file should contain a list of the settings to override:

logging.console.level=tracelogging.console.audit=true

Passing arguments to the underlying Node.js process

There are occasions when it is necessary to pass arguments to the underlyingNode.js process. For example, when running on devices like the Raspberry Pi orBeagleBone 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 providearguments for the node process before specifying red.js and the arguments youwant 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/

Upgrading Node-RED

Running Node-RED locally : Node-RED (8)Running Node-RED locally : Node-RED (9)Running Node-RED locally : Node-RED (10)

If you installed Node-RED using the Pi script, you can rerun it to upgrade. Thescript is available here.

If you have installed Node-RED as a global npm package, you can upgrade to thelatest version with the following command:

sudo npm install -g --unsafe-perm node-red

If you are using Windows, do not start the command with sudo.

Next steps

  • Learn how to secure your editor
  • Create your first flow
  • Starting Node-RED on boot
Running Node-RED locally : Node-RED (2024)
Top Articles
Latest Posts
Article information

Author: Corie Satterfield

Last Updated:

Views: 5816

Rating: 4.1 / 5 (42 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Corie Satterfield

Birthday: 1992-08-19

Address: 850 Benjamin Bridge, Dickinsonchester, CO 68572-0542

Phone: +26813599986666

Job: Sales Manager

Hobby: Table tennis, Soapmaking, Flower arranging, amateur radio, Rock climbing, scrapbook, Horseback riding

Introduction: My name is Corie Satterfield, I am a fancy, perfect, spotless, quaint, fantastic, funny, lucky person who loves writing and wants to share my knowledge and understanding with you.