Low-code programming platform for event-driven applications with visual flow-based editor and runtime system
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Node-RED's command-line interface provides tools for running the server, managing node modules, and administrative tasks. The CLI supports both server execution and administrative operations.
Start Node-RED server with various configuration options.
# Basic server startup
node-red
# With specific options
node-red [options]Command Line Options:
# Server configuration
-p, --port PORT # Port to listen on (default: 1880)
-s, --settings FILE # Settings file to use (default: ~/.node-red/settings.js)
--title TITLE # Process window title (default: node-red)
-u, --userDir DIR # User directory (default: ~/.node-red)
# Operation modes
-v, --verbose # Enable verbose output
--safe # Enable safe mode (starts without flows)
# Configuration overrides
-D, --define X=Y # Override settings values dynamically
# Information
--version # Show version information
--help # Show help information
# Privacy
--no-telemetry # Disable usage data sharingUsage Examples:
# Start on custom port
node-red -p 1881
# Use custom settings file
node-red -s ./my-settings.js
# Custom user directory
node-red -u ./node-red-data
# Safe mode (no flows loaded)
node-red --safe
# Verbose logging
node-red -v
# Override settings
node-red -D uiHost=127.0.0.1 -D httpNodeRoot=/api
# Show version
node-red --versionAdministrative operations using the admin command interface.
# Admin command syntax
node-red admin <command> [options]# Install node module
node-red admin install <module>[@version]
# Remove node module
node-red admin remove <module>
# Enable node module
node-red admin enable <module>
# Disable node module
node-red admin disable <module>
# List installed modules
node-red admin list [filter]
# Search for modules
node-red admin search <term>
# Show module information
node-red admin info <module>Usage Examples:
# Install specific node module
node-red admin install node-red-contrib-influxdb
# Install specific version
node-red admin install node-red-contrib-postgres@0.6.1
# Remove module
node-red admin remove node-red-contrib-influxdb
# List all installed modules
node-red admin list
# List core modules only
node-red admin list core
# Search for MQTT nodes
node-red admin search mqtt
# Get module information
node-red admin info node-red-contrib-influxdb# Initialize user directory
node-red admin init
# Generate password hash
node-red admin hash-pw [password]Usage Examples:
# Initialize new user directory with prompts
node-red admin init
# Generate password hash for settings.js
node-red admin hash-pw
# Enter password when prompted
# Generate hash for specific password
echo "mypassword" | node-red admin hash-pwNode-RED can be managed as a system service or run in various modes.
# Run as daemon (background process)
nohup node-red > node-red.log 2>&1 &
# Run with process manager
pm2 start node-red
pm2 start node-red --name "my-node-red"
# Docker execution
docker run -p 1880:1880 nodered/node-red
# systemd service (example unit file)
[Unit]
Description=Node-RED
After=syslog.target network.target
[Service]
ExecStart=/usr/bin/node-red --userDir /opt/node-red/.node-red
Restart=on-failure
KillSignal=SIGINT
User=nodered
Group=nodered
[Install]
WantedBy=multi-user.targetEnvironment variables that affect Node-RED behavior.
# Node-RED specific variables
NODE_RED_HOME # Override home directory detection
NODE_RED_OPTIONS # Additional command line options
# Node.js variables
NODE_ENV # Environment mode (development, production)
NODE_OPTIONS # Node.js runtime options
NODE_PATH # Additional module search paths
# System variables
HOME # User home directory (affects default userDir)
PORT # Port override (for cloud deployments)Usage Examples:
# Set environment mode
NODE_ENV=production node-red
# Increase Node.js memory limit
NODE_OPTIONS="--max-old-space-size=4096" node-red
# Custom home directory
NODE_RED_HOME=/opt/node-red node-red
# Cloud deployment with PORT override
PORT=8080 node-redLocation and structure of Node-RED configuration files.
# Default locations (in order of precedence)
./settings.js # Current directory
~/.node-red/settings.js # User directory
/usr/local/lib/node_modules/node-red/settings.js # Global installation~/.node-red/ # Default user directory
├── settings.js # Main configuration file
├── flows.json # Flow definitions
├── flows_cred.json # Encrypted credentials
├── .sessions.json # Editor sessions
├── .config.json # Editor configuration
├── lib/ # Custom modules directory
├── node_modules/ # Installed node modules
└── projects/ # Git projects (if enabled)Command-line options and techniques for debugging Node-RED.
# Enable debug logging
DEBUG=red:* node-red
# Specific debug categories
DEBUG=red:runtime:* node-red
DEBUG=red:comms,red:api node-red
# Verbose output
node-red -v
# Safe mode for troubleshooting
node-red --safe
# Custom log level in settings
node-red -D logging.console.level=debugDebug Categories:
red:* - All Node-RED debug outputred:runtime:* - Runtime system debuggingred:comms - WebSocket communicationred:api - HTTP API callsred:registry - Node registry operationsred:storage - Storage operationsCommon patterns for integrating Node-RED CLI in deployment scenarios.
FROM nodered/node-red:latest
# Copy custom settings
COPY settings.js /data/settings.js
# Install additional nodes
RUN npm install node-red-contrib-influxdb
# Expose port
EXPOSE 1880
# Start Node-RED
CMD ["node-red", "--userDir", "/data"]apiVersion: apps/v1
kind: Deployment
metadata:
name: node-red
spec:
replicas: 1
selector:
matchLabels:
app: node-red
template:
metadata:
labels:
app: node-red
spec:
containers:
- name: node-red
image: nodered/node-red:latest
ports:
- containerPort: 1880
env:
- name: NODE_ENV
value: "production"
command: ["node-red"]
args: ["--userDir", "/data", "--verbose"]
volumeMounts:
- name: node-red-data
mountPath: /data#!/bin/bash
# node-red-startup.sh
export NODE_ENV=production
export NODE_OPTIONS="--max-old-space-size=2048"
# Start Node-RED with custom configuration
node-red \
--userDir /opt/node-red/data \
--settings /opt/node-red/config/settings.js \
--port 1880 \
--verbose \
> /var/log/node-red.log 2>&1 &
echo $! > /var/run/node-red.pid
echo "Node-RED started with PID $(cat /var/run/node-red.pid)"Node-RED CLI exit codes and their meanings.
0 # Success
1 # General error
2 # Invalid arguments
3 # Node.js version incompatible
130 # Interrupted (Ctrl+C)Common CLI issues and solutions.
# Fix npm permissions for global install
sudo chown -R $(whoami) ~/.npm
sudo chown -R $(whoami) /usr/local/lib/node_modules
# Or use n or nvm for Node.js management# Find process using port 1880
lsof -i :1880
netstat -tulpn | grep :1880
# Use different port
node-red -p 1881# Clear npm cache
npm cache clean --force
# Rebuild native modules
npm rebuild
# Install with specific registry
node-red admin install --registry=https://registry.npmjs.org/ <module>