### Node-RED Installation Completion Message Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/08-pi-build-utilities.md Provides instructions on how to start Node-RED after installation and access it via a web browser. This message is displayed upon successful completion of the build utilities. ```bash echo "All done." echo " You can now start Node-RED with the command node-red-start" echo " or using the icon under Menu / Programming / Node-RED." echo " Then point your browser to http://127.0.0.1:1880 or http://{{your_pi_ip-address}:1880 ``` -------------------------------- ### Scripted Node-RED Installation (Non-Interactive) Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/02-deb-installer-api.md Performs a non-interactive installation of Node-RED using the installer script. This example confirms root actions, skips the Pi-specific setup, and sets a custom user. ```bash bash install-update-nodered \ --confirm-root \ --confirm-install \ --skip-pi \ --noredited-user=nodered ``` -------------------------------- ### Root Installation with Firewall Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/03-rpm-installer-api.md Installs Node-RED as root, confirming the root installation, opening the firewall, and confirming the installation. Requires the script to be present locally. ```bash bash update-nodejs-and-nodered \ --confirm-root \ --open-firewall \ --confirm-install ``` -------------------------------- ### Set Environment Variables for Node-RED Installation Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/03-rpm-installer-api.md Set environment variables to configure the Node-RED installation script. This example sets the user, enables the firewall, and skips confirmation prompts. ```bash export NODERED_USER=nodered export OPEN_FIREWALL=y export CONFIRM_INSTALL=y bash <(curl -sL https://github.com/node-red/linux-installers/releases/latest/download/update-nodejs-and-nodered) ``` -------------------------------- ### Example of skipping root confirmation Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/07-installation-environment-variables.md This example demonstrates how to skip the root confirmation prompt by setting the CONFIRM_ROOT environment variable to 'y' before executing the installation script. ```bash CONFIRM_ROOT=y bash <(curl -sL https://github.com/node-red/linux-installers/releases/latest/download/install-update-nodered) ``` -------------------------------- ### Install Node-RED on Debian/Pi OS Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/INDEX.md Installs Node-RED using a script for Debian-based systems like Raspberry Pi OS. The script guides through interactive prompts and automatically starts the service. ```bash # Debian/Pi OS bash <(curl -sL https://github.com/node-red/linux-installers/releases/latest/download/install-update-nodered) # Interactive prompts will guide you through setup # Service automatically starts after installation ``` -------------------------------- ### Automate Node-RED installation with CONFIRM_INSTALL Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/07-installation-environment-variables.md Set CONFIRM_INSTALL to 'y' to skip all installation confirmations, including root, user selection, Pi nodes, and settings initialization. This enables a fully automated installation. ```bash export CONFIRM_ROOT=y export CONFIRM_INSTALL=y export NODERED_USER=nodered bash install-update-nodered ``` -------------------------------- ### Execute RPM Installer Script Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/03-rpm-installer-api.md Download and execute the Node-RED RPM installer script directly from GitHub. This is the simplest way to install or update Node-RED. ```bash bash <(curl -sL https://github.com/node-red/linux-installers/releases/latest/download/update-nodejs-and-nodered) ``` -------------------------------- ### Start Node-RED Service (Sudo User) Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/05-service-management-api.md Starts the Node-RED service using systemctl and streams its logs. This is for users in the sudo group. ```bash sudo systemctl start nodered sudo journalctl -f -n 1 -u nodered -o cat ``` -------------------------------- ### Install Node.js and NPM using APT Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/02-deb-installer-api.md Installs Node.js and npm packages using the APT package manager. This is conditional and only runs if Node.js is not already installed or if Node.js installation is forced. ```bash if HAS_NODE && [ -z "$FORCE_NODE" ]; then echo "Node.js already installed, keeping existing version" else apt install nodejs npm fi ``` -------------------------------- ### Installer Option Parsing Logic Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/02-deb-installer-api.md Demonstrates the shell script logic for parsing command-line arguments passed to the Node-RED Debian installer. It handles various flags and options to customize the installation process. ```bash while (( "$#" )); do case "$1" in --help) usage && exit 0 ;; --confirm-root) CONFIRM_ROOT="y" ;; --confirm-install) CONFIRM_INSTALL="y" ;; --confirm-pi) CONFIRM_PI="y" ;; --skip-pi) CONFIRM_PI="n" ;; --update-nodes) UPDATENODES="y" ;; --noredited-version=*) NODERED_VERSION="${1#*=}" ;; --nodered-user=*) NODERED_USER="${1#*=}" ;; --node22|--node24|--node26) FORCE_NODE="y"; NODE_VERSION="${1##*--node}" ;; --allow-low-ports) LOW_PORTS="y" ;; --no-init) INITSET="n" ;; --on-diet) ONDIET="y" ;; *) echo "Error: Unsupported flag $1" >&2; exit 1 ;; esac shift done ``` -------------------------------- ### Cloud-Init Script for Node-RED Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/07-installation-environment-variables.md Automates Node-RED installation using Cloud-Init. Sets environment variables for confirmation and user before executing the install script. ```yaml #!/bin/cloud-config runcmd: - export CONFIRM_INSTALL=y - export NODERED_USER=nodered - bash <(curl -sL https://github.com/node-red/linux-installers/releases/latest/download/install-update-nodered) ``` -------------------------------- ### Node-RED Environment File Example Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/06-configuration.md Example content for the user's environment file, allowing customization of Node.js options, Node-RED options, and HTTP proxy settings. ```bash # /home/pi/.node-red/environment NODE_OPTIONS="--max_old_space_size=1024" NODE_RED_OPTIONS="-v" HTTP_PROXY="http://proxy.example.com:8080" ``` -------------------------------- ### Start Node-RED Service (Root User) Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/05-service-management-api.md Starts the Node-RED service using systemctl and streams its logs. This is for users running as root. ```bash systemctl start nodered journalctl -f -n 1 -u nodered -o cat ``` -------------------------------- ### Check npm Installation Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/05-service-management-api.md Verifies if npm is installed on the system. npm is required for installing additional Node-RED nodes. ```bash if [[ ! $(which npm) ]]; then echo "npm is not installed..." fi ``` -------------------------------- ### Typical Usage of Node-RED Build Scripts Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/08-pi-build-utilities.md Run the installation script first, then the packaging script to create a .deb file. ```bash bash node-red-pi-install.sh # Build Node-RED bash node-red-deb-pack.sh # Create .deb package ``` -------------------------------- ### Basic Node-RED Installation (Debian) Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/README.md Installs or updates Node-RED using the official script. Ensure you have curl installed. See linked documentation for available options. ```bash bash <(curl -sL https://github.com/node-red/linux-installers/releases/latest/download/install-update-nodered) ``` -------------------------------- ### Non-interactive Node-RED Installation with Firewall Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/03-rpm-installer-api.md Installs Node-RED non-interactively, specifying the user, opening the firewall, and confirming the installation. Requires the script to be present locally. ```bash bash update-nodejs-and-nodered \ --noredited-user=nodered \ --open-firewall \ --confirm-install ``` -------------------------------- ### Node-RED Installation using Environment Variables Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/03-rpm-installer-api.md Configures Node-RED installation using environment variables for user, firewall, and confirmation. The script must be present locally. ```bash NODERED_USER=nodered \ OPEN_FIREWALL=y \ CONFIRM_INSTALL=y \ bash update-nodejs-and-nodered ``` -------------------------------- ### Run Node-RED PI Install Script Source: https://github.com/node-red/linux-installers/blob/master/pibuild/README.md Execute the primary installation script for Node-RED. This script updates package lists, installs Node.js and npm, installs the latest Node-RED from npm, adds extra nodes, cleans up unnecessary files, and sets up icon, init, and desktop files. Recommended to run only once on a clean system. ```bash ./node-red-pi-install.sh ``` -------------------------------- ### node-red-start Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/API-SURFACE.md Starts the Node-RED service. This script is available in `/usr/bin/` post-installation and streams logs upon service startup. ```APIDOC ## node-red-start ### Description Starts the Node-RED service. This script is available in `/usr/bin/` post-installation and streams logs upon service startup. ### Method Executable shell script ### Endpoint `/usr/bin/node-red-start` (post-installation) ### Parameters None ### Return Value Service exit code ``` -------------------------------- ### Start Node-RED Directly (Unprivileged User) Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/05-service-management-api.md Starts Node-RED directly without using systemd. This method is for unprivileged users and requires the 'node-red-pi' command. ```bash node-red-pi ``` -------------------------------- ### Install Development Tools on RPM-based Linux Source: https://github.com/node-red/linux-installers/blob/master/README.md Install the necessary development tools for compiling extra nodes on RPM-based systems. ```bash dnf groupinstall "Development Tools" ``` -------------------------------- ### Start Node-RED Service Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/05-service-management-api.md Starts the Node-RED systemd service. Use this command to initiate the Node-RED process. It displays startup information and logs. ```bash node-red-start ``` -------------------------------- ### systemd Service Configuration: Alternative ExecStart Command Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/06-configuration.md An alternative command to start Node-RED directly using Node.js, useful if 'node-red-pi' is not available. ```ini #ExecStart=/usr/bin/env node $NODE_OPTIONS red.js -- $NODE_RED_OPTIONS ``` -------------------------------- ### Append to Node-RED Installation Log Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/03-rpm-installer-api.md Appends a message to the Node-RED installation log file, typically used for recording installation steps and status. ```bash echo "message" | sudo tee -a /var/log/nodered-install.log >>/dev/null ``` -------------------------------- ### Execute RPM Installer with Options Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/03-rpm-installer-api.md Execute the Node-RED RPM installer script with command-line options. Use this to specify the Node-RED user or open firewall ports. ```bash curl -sL https://github.com/node-red/linux-installers/releases/latest/download/update-nodejs-and-nodered | \ bash -s -- --nodered-user=nodered --open-firewall ``` -------------------------------- ### Scripted Production Deployment of Node-RED Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/INDEX.md Performs a non-interactive production deployment of Node-RED using environment variables. The service starts automatically after installation. ```bash # Environment variables for scripted deployment nodered_USER=nodered \ nODERED_VERSION="5.0.0" \ CONFIRM_INSTALL=y \ bash <(curl -sL https://github.com/node-red/linux-installers/releases/latest/download/install-update-nodered) # No prompts, automatic service start ``` -------------------------------- ### Node-RED RPM Installer Options Source: https://github.com/node-red/linux-installers/blob/master/README.md Command-line options and environment variables for customizing the Node-RED installation on RPM-based systems. ```bash --help display this help and exits. ``` ```bash --nodered-user= specify the user to run as e.g. '--nodered-user=nodered'. ``` ```bash --confirm-root install as root without asking confirmation. ``` ```bash --open_firewall adding public firewall rule for node-red port 1880. ``` ```bash --confirm-install confirm the installation without asking a confirmation. ``` ```bash NODERED_USER=nodered ``` ```bash OPEN_FIREWALL=y ``` ```bash CONFIRM_ROOT=y ``` ```bash CONFIRM_INSTALL=y ``` -------------------------------- ### Run Node-RED Pi Install Script Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/08-pi-build-utilities.md Execute the main script to build a pre-configured Node-RED installation image for Raspberry Pi. This script should be run as the root user. ```bash bash node-red-pi-install.sh ``` -------------------------------- ### Install Node-RED Globally via NPM Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/02-deb-installer-api.md Installs the latest version of Node-RED globally using npm. It uses unsafe-perm and no-progress flags for a smoother installation process. ```bash npm install -g --unsafe-perm --no-progress \ node-red@${NODERED_VERSION:-latest} ``` -------------------------------- ### Skip Root Confirmation During Installation Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/07-installation-environment-variables.md Set CONFIRM_ROOT to 'y' to bypass the confirmation prompt when running the installer as root. This is useful for automated installations. ```bash export CONFIRM_ROOT=y bash update-nodejs-and-nodered ``` -------------------------------- ### Install Node-RED on Debian/Ubuntu/Raspberry Pi OS Source: https://github.com/node-red/linux-installers/blob/master/README.md Execute this command to install or update Node-RED on Debian-based systems. Ensure build tools are installed separately if needed for extra nodes. ```bash bash <(curl -sL https://github.com/node-red/linux-installers/releases/latest/download/install-update-nodered-deb) ``` ```bash sudo apt install build-essential ``` -------------------------------- ### Install Node-RED 2.x LTS Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/08-pi-build-utilities.md Installs Node-RED version 2.x LTS using npm. The --unsafe-perm flag allows installation with higher privileges, --no-progress suppresses the progress bar, and --production skips development dependencies. ```bash sudo npm cache clean --force sudo npm i -g --unsafe-perm --no-progress --production node-red@2.* ``` -------------------------------- ### Diff Output Example Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/04-merge-settings-api.md Illustrates the diff output format, showing patched local values, local-only keys to be preserved, and indicating when no changes are needed. ```text 📋 Existing Local values that will be patched kept in (2): ~ port new setting : 1880 local value : 8080 ~ adminAuth new setting : (commented) local value : { /* custom */ } ⚠️ Local-only keys not found in new settings — will be preserved (1): + customKey ``` -------------------------------- ### Verify Node.js and NPM Installation Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/03-rpm-installer-api.md Checks if Node.js and npm are installed correctly by attempting to retrieve their versions. Outputs the versions or an error message. ```bash if nov=$(node -v 2>/dev/null) && npv=$(npm -v 2>/dev/null); then echo "Node $nov Npm $npv" else echo "Failed to install Node.js" exit 2 fi ``` -------------------------------- ### Set Node-RED Version for Installation Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/07-installation-environment-variables.md Use the NODERED_VERSION environment variable to specify a particular Node-RED version for installation. If unset, the latest version is installed. ```bash export NODERED_VERSION="5.0.0" bash install-update-nodered ``` ```bash # Install Node-RED 4.1.2 export NODERED_VERSION="4.1.2" bash install-update-nodered ``` -------------------------------- ### Node-RED Installation Output State (RPM) Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/API-SURFACE.md Output state preserved after Node-RED installation on RPM-based systems. ```bash NODERED_USER: username running service NODERED_GROUP: primary group of user NODERED_HOME: home directory ``` -------------------------------- ### Node-RED Installation Output State (Debian) Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/API-SURFACE.md Output state preserved for the Node-RED service after installation on Debian. ```bash NODERED_USER: username running service NODERED_HOME: home directory of service user NODE_VERSION: major version of installed Node.js ``` -------------------------------- ### Set up NodeSource Repository for Node.js Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/03-rpm-installer-api.md Installs the NodeSource repository configuration for Node.js version 18.x on RPM-based systems. ```bash sudo yum install https://rpm.nodesource.com/pub_18.x/nodistro/repo/nodesource-release-nodistro-1.noarch.rpm -y ``` -------------------------------- ### Control Pi node installation with CONFIRM_PI Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/07-installation-environment-variables.md Use CONFIRM_PI to automatically confirm or skip the installation of Raspberry Pi specific nodes. Set to 'y' to install, 'n' to skip. ```bash # Install Pi nodes without asking export CONFIRM_PI=y bash install-update-nodered # Skip Pi nodes without asking export CONFIRM_PI=n bash install-update-nodered ``` -------------------------------- ### RPM Installer Option Parsing Logic Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/03-rpm-installer-api.md This bash script snippet demonstrates how the installer parses command-line options like `--confirm-root`, `--confirm-install`, `--open-firewall`, and `--noredited-user`. ```bash while (( "$#" )); do case "$1" in --help) usage && exit 0 ;; --confirm-root) CONFIRM_ROOT="y" ;; --confirm-install) CONFIRM_INSTALL="y" ;; --open-firewall) OPEN_FIREWALL="y" ;; --noredited-user=*) NODERED_USER="${1#*=}" ;; *) echo "Error: Unsupported flag $1" >&2; exit 1 ;; esac shift done ``` -------------------------------- ### Force installation on DietPi with ONDIET Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/07-installation-environment-variables.md Use ONDIET=y to override DietPi system detection and force a full Node-RED installation. Use with caution as DietPi has its own package management. ```bash # Force install on DietPi (use with caution) export ONDIET=y bash install-update-nodered ``` -------------------------------- ### Logging to Node-RED Install Log Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/02-deb-installer-api.md Appends a message to the Node-RED installation log file. Ensure you have the necessary permissions to write to /var/log/nodered-install.log. ```bash echo "message" | $SUDO tee -a /var/log/nodered-install.log >>/dev/null ``` -------------------------------- ### Dockerfile for Node-RED Deployment Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/07-installation-environment-variables.md Sets up a Docker image with Node-RED installed. Environment variables are exported before running the installation script. Exposes port 1880. ```dockerfile FROM ubuntu:22.04 RUN export CONFIRM_INSTALL=y && \ export NODERED_USER=nodered && \ bash <(curl -sL https://github.com/node-red/linux-installers/releases/latest/download/install-update-nodered) EXPOSE 1880 CMD ["node-red-start"] ``` -------------------------------- ### Clean Previous Node.js and Node-RED Installations Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/08-pi-build-utilities.md Removes existing Node.js installations, npm caches, and related configuration files to ensure a clean slate before a new installation. Run with sudo. ```bash sudo rm -rf /usr/lib/node_modules/ sudo rm -rf /usr/bin/node-red* sudo rm -rf /usr/local/lib/node_modules/ sudo rm -rf /usr/local/bin/node-red* sudo rm -rf /home/pi/.npm /home/pi/.node-gyp sudo rm -rf /root/.npm /root/.node-gyp sudo rm -rf /etc/apt/sources.list.d/nodesource.list ``` -------------------------------- ### Confirm Node-RED Installation User Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/03-rpm-installer-api.md Prompts for explicit user confirmation before proceeding with the installation if NODERED_USER is set and CONFIRM_INSTALL is not 'y'. Exits if not confirmed. ```bash if [[ -n "${NODERED_USER}" ]] && [[ "${CONFIRM_INSTALL}" == "n" ]]; then read -p "Confirm install as user '${NODERED_USER}'? [y/N] " yn [[ "$yn" =~ ^[Yy]$ ]] || exit 1 fi ``` -------------------------------- ### Node-RED System Installation Directory Structure Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/API-SURFACE.md This structure represents the default locations for Node-RED package files, binaries, service scripts, and configuration files when installed system-wide. ```bash /usr/lib/node_modules/node-red/ Node-RED package /usr/bin/node Node.js binary /usr/bin/npm npm binary /usr/bin/node-red-* Service scripts /lib/systemd/system/nodered.service systemd unit /etc/firewalld/services/nodered.xml Firewall rules /etc/logrotate.d/nodered Log rotation /usr/share/icons/hicolor/*/apps/* Icon files /usr/share/applications/*.desktop Desktop entry ``` -------------------------------- ### Skip All Installation Confirmations Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/07-installation-environment-variables.md Use CONFIRM_INSTALL='y' to skip all interactive confirmation prompts during the installation process, including user selection, firewall configuration, and root checks. This enables the use of default settings. ```bash export CONFIRM_INSTALL=y bash update-nodejs-and-nodered ``` -------------------------------- ### Install Node.js using YUM Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/03-rpm-installer-api.md Installs Node.js using the YUM package manager, enabling hotfixes for modules. ```bash sudo yum install nodejs -y --setopt=nodesource-nodejs.module_hotfixes=1 ``` -------------------------------- ### Download Node-RED Helper Scripts (RPM) Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/03-rpm-installer-api.md Installs Node-RED helper scripts like node-red-start using curl. Ensures the script is executable and checks for successful download. ```bash if curl -f https://raw.githubusercontent.com/node-red/linux-installers/master/resources/node-red-icon.svg >/dev/null 2>&1 then sudo curl -sL -o /usr/bin/node-red-start \ https://raw.githubusercontent.com/node-red/linux-installers/master/resources/node-red-start.rpm # ... repeat for other files sudo chmod +x /usr/bin/node-red-* echo "$TICK" else echo "$CROSS" fi ``` -------------------------------- ### Install Dependencies for Node-RED Build Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/08-pi-build-utilities.md Updates the package list and installs essential build tools, Node.js, npm, and lintian for Debian package quality checking. Run with sudo. ```bash sudo apt-get update sudo apt-get install -y build-essential nodejs npm lintian ``` -------------------------------- ### Start Node-RED Service Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/API-SURFACE.md Executes the Node-RED service and streams its logs. No parameters are required. ```bash $ node-red-start # Starts service and streams logs ``` -------------------------------- ### Node-RED systemd Service Start Command Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/02-deb-installer-api.md This is the command executed by the systemd service to start Node-RED. It includes options for environment variables and Node-RED specific arguments. ```bash ExecStart=/usr/bin/env node-red-pi $NODE_OPTIONS -- $NODE_RED_OPTIONS ``` -------------------------------- ### Install Node-RED Pi Debian Package Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/08-pi-build-utilities.md Use dpkg or apt to install the Node-RED Pi Debian package. Ensure you have the correct package name and version. ```bash sudo dpkg -i node-red-pi_2.x.x_armhf.deb # or sudo apt install ./node-red-pi_2.x.x_armhf.deb ``` -------------------------------- ### Install Node-RED Globally Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/03-rpm-installer-api.md Installs or updates the Node-RED core package globally using npm. It uses unsafe-perm and disables progress output, logging the process. ```bash sudo npm i -g --unsafe-perm --no-progress node-red@latest \ 2>&1 | sudo tee -a /var/log/nodered-install.log >>/dev/null ``` -------------------------------- ### Install Pi-Specific Node-RED Nodes Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/08-pi-build-utilities.md Installs several Node-RED nodes commonly used on Raspberry Pi, including GPIO control, network utilities, and data processing nodes. Run with sudo. ```bash mkdir -p ~/.node-red echo "Node-RED installed. Adding a few extra nodes" sudo npm install -g --unsafe-perm --no-progress \ node-red-node-pi-gpio \ node-red-node-random \ node-red-node-ping \ node-red-node-smooth \ node-red-contrib-play-audio \ node-red-node-serialport \ node-red-contrib-buffer-parser ``` -------------------------------- ### Ansible Playbook for Node-RED Installation Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/07-installation-environment-variables.md Installs Node-RED using an Ansible playbook, setting environment variables for user, version, and confirmation. Requires root privileges. ```yaml - name: Install Node-RED shell: | NODERED_USER=nodered \ NODERED_VERSION="5.0.0" \ CONFIRM_INSTALL=y \ bash <(curl -sL https://github.com/node-red/linux-installers/releases/latest/download/install-update-nodered) become: yes ``` -------------------------------- ### Set up Initial User package.json for Node-RED Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/03-rpm-installer-api.md Creates a basic package.json file in the user's .node-red directory if one does not exist. It also configures npm to disable update notifications and creates a node_modules directory. ```bash sudo su - ${NODERED_USER} <<'EOF' cd mkdir -p ".node-red/node_modules" cd .node-red npm config set update-notifier false if [ ! -f "package.json" ]; then cat > package.json <<'PKGJSON' { "name": "node-red-project", "description": "initially created for you by Node-RED ", "version": "0.0.1", "dependencies": {} } PKGJSON fi EOF ``` -------------------------------- ### Detect DietPi Environment and Adjust Installation Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/02-deb-installer-api.md Checks for the presence of the DietPi user data directory. If detected and not already configured for DietPi, it adjusts the installation to only include Node-RED command-line tools. ```bash if [[ -e /mnt/dietpi_userdata && "$ONDIET" != "y" ]]; then # DietPi detected — install only node-red-start/stop/log commands # Exit after creating wrapper scripts fi ``` -------------------------------- ### Install Node-RED on RPM-based Linux Source: https://github.com/node-red/linux-installers/blob/master/README.md Use this command for installing or updating Node-RED on RPM-based systems like Fedora or CentOS. It can be configured with options for user and firewall. ```bash bash <(curl -sL https://github.com/node-red/linux-installers/releases/latest/download/update-nodejs-and-nodered-rpm) ``` ```bash curl -sL https://github.com/node-red/linux-installers/releases/latest/download/update-nodejs-and-nodered-rpm \ | bash -s --nodered-user=nodered --open-firewall ``` ```bash NODERED_USER=nodered bash <(curl -sL https://github.com/node-red/linux-installers/releases/latest/download/update-nodejs-and-nodered-rpm) ``` -------------------------------- ### Enable Node-RED Systemd Service Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/03-rpm-installer-api.md Reloads the systemd daemon and enables the Node-RED service to start on boot. ```bash sudo systemctl daemon-reload sudo systemctl enable nodered ``` -------------------------------- ### systemd Service Configuration: Time Sync Wait (Optional) Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/06-configuration.md An optional ExecStartPre command to ensure systemd-timesyncd has synchronized time before starting Node-RED. Uncomment to enable. ```ini #ExecStartPre=/bin/bash -c '/bin/journalctl -b -u systemd-timesyncd | /bin/grep -q "systemd-timesyncd.* Synchronized to time server"' ``` -------------------------------- ### Install/Update Node-RED Script Options Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/API-SURFACE.md Use this script to install or update Node-RED and its dependencies. Options control confirmation prompts, Pi node handling, Node.js versions, and service configuration. ```bash install-update-nodered [options] ``` ```bash curl | bash install-update-nodered [options] ``` -------------------------------- ### systemd Unit Section Configuration Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/06-configuration.md Defines basic service information like description, dependencies, and documentation links. Ensure 'network.target' is suitable for your network setup. ```ini [Unit] Description=Node-RED graphical event wiring tool Wants=network.target Documentation=http://nodered.org/docs/hardware/raspberrypi.html ``` -------------------------------- ### Command-line Option Precedence Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/07-installation-environment-variables.md Demonstrates that command-line options always override environment variables during installation. Use this to ensure specific configurations are applied. ```bash export NODERED_USER=user1 bash install-update-nodered --nooded-user=user2 # Result: Installs as user2 (flag takes precedence) ``` -------------------------------- ### Apply Node-RED Firewall Rule During RPM Installation Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/06-configuration.md Opens the Node-RED port (1880) in the firewall during an RPM installation when the --open-firewall option is used. Logs the command's output to a file. ```bash sudo firewall-cmd --permanent --add-service=nodered \ 2>&1 | tee -a /var/log/nodered-install.log >>/dev/null ``` -------------------------------- ### findModuleExportsStart(src) Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/API-SURFACE.md Finds the starting index of the '{' in a `module.exports = {` statement. ```APIDOC ## findModuleExportsStart(src) ### Description Finds index of `{` in `module.exports = {`. ### Parameters - **src** (string) - The source code string. ### Returns - (number) - The index of the opening brace '{'. ``` -------------------------------- ### Command-Line Usage Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/04-merge-settings-api.md Illustrates the basic command structure for using the merge-settings utility, including parameters and optional flags. ```bash node merge-settings.js [output-file] [--flags] ``` -------------------------------- ### Set CONFIRM_ROOT to skip root confirmation Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/07-installation-environment-variables.md Use this variable to skip confirmation prompts when running the installation script as root. Set to 'y' or 'Y' to bypass. ```bash export CONFIRM_ROOT=y bash install-update-nodered ``` -------------------------------- ### Clone Node-RED Linux Installers Repository Source: https://github.com/node-red/linux-installers/blob/master/pibuild/README.md Clone the repository containing the build scripts to your Raspberry Pi. ```bash git clone https://github.com/node-red/linux-installers.git cd linux-installers/pibuild ``` -------------------------------- ### Open Firewall for Node-RED on RPM-based Systems Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/06-configuration.md Automatically open the necessary firewall port for Node-RED on RPM-based systems using the `firewall-cmd` utility. This is typically done via an installer flag. ```bash sudo firewall-cmd --permanent --add-service=nodered ``` -------------------------------- ### Relocate Node-RED to Standard Paths Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/08-pi-build-utilities.md Moves Node-RED installations from /usr/local to standard system paths like /usr/lib and /usr/bin. This ensures consistency with system package management. ```bash echo "Move everything under /usr rather than /usr/local" sudo mkdir -p /usr/lib/node_modules sudo mv /usr/local/lib/node_modules/node-red* /usr/lib/node_modules/ sudo mv /usr/local/bin/node* /usr/bin/ ``` -------------------------------- ### Force Node.js Version 22 Installation Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/02-deb-installer-api.md Installs or updates Node-RED, forcing the use of Node.js version 22. Requires confirmation for the installation step. ```bash bash install-update-nodered \ --node22 \ --confirm-install ``` -------------------------------- ### Define ARMv6 Node.js Version for Installation Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/02-deb-installer-api.md Specifies the exact version of Node.js (v22.22.3) to be used for ARMv6 architecture, sourced from unofficial builds. ```bash tgta22=22.22.3 # ARMv6 latest from unofficial-builds.nodejs.org ``` -------------------------------- ### Create Backup File Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/04-merge-settings-api.md Creates a backup of the local settings file by copying it to a new file with a .bak extension before writing any output. ```javascript const backupPath = localPath + '.bak'; fs.copyFileSync(localPath, backupPath); ``` -------------------------------- ### Specify Node-RED User for RPM Installer Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/07-installation-environment-variables.md Use the NODERED_USER environment variable to define the system user under which the Node-RED service will run. The user will be created if it does not exist. ```bash export NODERED_USER=nodered bash <(curl -sL https://github.com/node-red/linux-installers/releases/latest/download/update-nodejs-and-nodered) ``` -------------------------------- ### Install Node-RED Service Files and Scripts Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/08-pi-build-utilities.md Copies systemd service files, management scripts, an icon, and a desktop entry to their respective system locations. Ensure the 'resources' directory is present before execution. ```bash if [ -d "resources" ]; then cd resources sudo chown root:root * sudo chmod +x node-red-st* sudo chmod +x node-red-re* sudo chmod +x node-red-log # Copy systemd service file sudo cp nodered.service /lib/systemd/system/ sudo cp nodered.service /tmp/ # Copy service management scripts sudo cp node-red-start /usr/bin/ sudo cp node-red-stop /usr/bin/ sudo cp node-red-restart /usr/bin/ sudo cp node-red-reload /usr/bin/ sudo cp node-red-log /usr/bin/ # Install icon and desktop file sudo cp node-red-icon.svg /usr/share/icons/hicolor/scalable/apps/node-red-icon.svg sudo chmod 644 /usr/share/icons/hicolor/scalable/apps/node-red-icon.svg sudo cp Node-RED.desktop /usr/share/applications/Node-RED.desktop cd .. else echo "resources - subdirectory not in place... exiting." exit 1 fi ``` -------------------------------- ### Basic Merge (in-place) Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/04-merge-settings-api.md Overwrites the local settings file after creating a backup. Use this for direct updates. ```bash node merge-settings.js \ ~/.node-red/settings.js \ /usr/lib/node_modules/node-red/settings.js ``` -------------------------------- ### Desktop Entry Configuration Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/API-SURFACE.md Desktop Entry (.desktop) file format for creating application launchers in desktop environments. Includes details like name, comment, execution command, and icon. ```ini [Desktop Entry] Version: string Type: string ("Application") Name: string Comment: string Exec: string (command) Icon: string (icon name) Categories: string (semicolon-separated) Terminal: boolean ``` -------------------------------- ### Detect Installed Node-RED Version Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/03-rpm-installer-api.md Retrieves and displays the currently installed global version of the Node-RED package using npm. ```bash nrv=$(npm --no-progress -g ls node-red | grep node-red | cut -d '@' -f 2) echo "Install Node-RED core $CHAR $nrv" ``` -------------------------------- ### Node-RED Installation Environment Variables (RPM) Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/API-SURFACE.md Environment variables used during Node-RED installation on RPM-based systems. These control user and firewall settings. ```bash NODERED_USER: string → username CONFIRM_ROOT: "y" | "n" | other → boolean flag CONFIRM_INSTALL: "y" | "n" | other → boolean flag OPEN_FIREWALL: "y" | "n" | other → boolean flag ``` -------------------------------- ### Automated Node-RED Deployment with Environment Variables Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/README.md Automates Node-RED installation or update by setting environment variables for user, version, and confirmation. This is useful for scripting deployments. See linked documentation for all available variables. ```bash NODERED_USER=nodered \ NODERED_VERSION="5.0.0" \ CONFIRM_INSTALL=y \ bash <(curl -sL https://github.com/node-red/linux-installers/releases/latest/download/install-update-nodered) ``` -------------------------------- ### Update Node-RED to a Specific Version Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/02-deb-installer-api.md Updates Node-RED to a specific version (e.g., 5.0.0) using the installer script. Requires confirmation for the installation. ```bash bash install-update-nodered \ --noredited-version="5.0.0" \ --confirm-install ``` -------------------------------- ### Node-RED Installation Environment Variables (Debian) Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/API-SURFACE.md Environment variables used during Node-RED installation on Debian systems. These control confirmation prompts and user settings. ```bash CONFIRM_ROOT: "y" | "n" | other → boolean flag CONFIRM_INSTALL: "y" | "n" | other → boolean flag CONFIRM_PI: "y" | "n" | other → boolean flag INITSET: "y" | "n" | other → boolean flag ONDIET: "y" | "n" | other → boolean flag UPDATENODES: "y" | "n" | other → boolean flag NODERED_USER: string → username NODERED_VERSION: string → version number LOW_PORTS: "y" | "n" | other → boolean flag ``` -------------------------------- ### Enable Low Port Binding for Node-RED Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/02-deb-installer-api.md Installs or updates Node-RED and enables the binding to low port numbers (below 1024). Requires confirmation for the installation. ```bash bash install-update-nodered \ --allow-low-ports \ --confirm-install ``` -------------------------------- ### Check if npm is Installed Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/02-deb-installer-api.md A bash function that returns 0 if the 'npm' command is found and executable, indicating npm is installed. Otherwise, it returns 1. ```bash function HAS_NPM { if [ -x "$(command -v npm)" ]; then return 0; else return 1; fi } ``` -------------------------------- ### Check if Node.js is Installed Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/02-deb-installer-api.md A bash function that returns 0 if the 'node' command is found and executable, indicating Node.js is installed. Otherwise, it returns 1. ```bash function HAS_NODE { if [ -x "$(command -v node)" ]; then return 0; else return 1; fi } ``` -------------------------------- ### Configure Node-RED User (Root) Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/03-rpm-installer-api.md Sets the Node-RED home directory to '/root' if the script is run as root and NODERED_USER is not set. Prompts for confirmation. ```bash if [[ "${EUID}" == "0" ]] && [[ -z "${NODERED_USER}" ]]; then read -p "Install as root user? [y/N] " yn [[ "$yn" =~ ^[Yy]$ ]] && export NODERED_HOME=/root fi ``` -------------------------------- ### buildOrphanInsertions(upstreamSrc, upstreamObjStart, localMap) Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/API-SURFACE.md Identifies keys present in the local configuration but not in the upstream, and generates insertion points. ```APIDOC ## buildOrphanInsertions(upstreamSrc, upstreamObjStart, localMap) ### Description Finds local keys not present in upstream, generates insertion points. ### Parameters - **upstreamSrc** (string) - The source code of the upstream configuration. - **upstreamObjStart** (number) - The starting index of the upstream object literal. - **localMap** (object) - The parsed source map of the local configuration. ### Returns - (object) - An object containing `replacements` and `diffs`. ``` -------------------------------- ### deb/install-update-nodered Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/API-SURFACE.md Installs or updates Node-RED and its dependencies on Debian-based systems. It can be invoked directly via bash or through a curl pipe, accepting various options to customize the installation process. ```APIDOC ## deb/install-update-nodered ### Description Installs or updates Node-RED and its dependencies on Debian-based systems. It can be invoked directly via bash or through a curl pipe, accepting various options to customize the installation process. ### Method Executable shell script ### Endpoint `/usr/bin/install-update-nodered` (post-installation) ### Parameters #### Invocation `bash install-update-nodered [options]` or `curl | bash` #### Exported Options - `--help` - Display help and exit - `--confirm-root` - Skip root confirmation - `--confirm-install` - Skip all confirmations - `--confirm-pi` - Auto-confirm Pi nodes installation - `--skip-pi` - Skip Pi nodes installation - `--update-nodes` - Run npm update on existing nodes - `--allow-low-ports` - Enable low port binding - `--no-init` - Skip settings initialization - `--on-diet` - Override DietPi detection - `--nodered-user=` - Specify service user - `--nodered-version=` - Specify Node-RED version - `--node22` - Force Node.js version 22 - `--node24` - Force Node.js version 24 - `--node26` - Force Node.js version 26 #### Environment Variables - `CONFIRM_ROOT` - `CONFIRM_INSTALL` - `CONFIRM_PI` - `INITSET` - `ONDIET` - `UPDATENODES` - `NODERED_USER` - `NODERED_VERSION` - `LOW_PORTS ### Return Values - 0: Success - 1: Validation/fatal error - 2: Installation failed ``` -------------------------------- ### Prompt for Firewall Configuration Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/03-rpm-installer-api.md Interactively prompts the user to add Node-RED's port 1880 to the firewall's public zone. This prompt has a 15-second timeout unless CONFIRM_INSTALL is set. ```bash if [[ -z "${OPEN_FIREWALL}" ]] && [[ "${CONFIRM_INSTALL}" == "n" ]]; then read -r -t 15 -p "Add Node-RED port 1880 to firewall public zone? [y/N] " response [[ "$response" =~ ^([yY])+$ ]] && OPEN_FIREWALL="y" fi ``` -------------------------------- ### Build Debian Package with dpkg-deb Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/08-pi-build-utilities.md Command to construct the .deb package file from the prepared package directory structure. ```bash dpkg-deb --build node-red-pi/ node-red-pi_2.x.x_armhf.deb ``` -------------------------------- ### Update installed nodes with UPDATENODES Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/07-installation-environment-variables.md Set UPDATENODES to 'y' to run `npm update` on existing installed nodes after upgrading Node-RED. This updates node packages within their semver constraints. ```bash # Update node packages within package.json scope export UPDATENODES=y bash install-update-nodered ``` -------------------------------- ### Upgrade Node-RED with Settings Preservation Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/INDEX.md Upgrades an existing Node-RED installation, preserving settings. The installer handles upgrades automatically, and settings are merged using merge-settings.js, with a backup created. ```bash # Run installer (handles all upgrades automatically) bash install-update-nodered --confirm-install # Settings merge automatic via merge-settings.js # Backup saved to settings.js.bak ``` -------------------------------- ### buildReplacements(upstreamSrc, upstreamObjStart, localMap) Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/API-SURFACE.md Generates a list of text replacements needed to update local settings based on upstream changes. ```APIDOC ## buildReplacements(upstreamSrc, upstreamObjStart, localMap) ### Description Returns list of text replacements to apply. ### Parameters - **upstreamSrc** (string) - The source code of the upstream configuration. - **upstreamObjStart** (number) - The starting index of the upstream object literal. - **localMap** (object) - The parsed source map of the local configuration. ### Returns - (array) - An array of replacement objects. - **start** (number) - The starting character index for the replacement. - **end** (number) - The ending character index for the replacement. - **text** (string) - The replacement text. ``` -------------------------------- ### Create Node-RED User Directories Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/03-rpm-installer-api.md Creates the necessary hidden directories for Node-RED user configurations and modules. ```bash mkdir -p ${NODERED_HOME}/.node-red mkdir -p ${NODERED_HOME}/.node-red/node_modules ``` -------------------------------- ### Node-RED Terminal Coloring Example Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/05-service-management-api.md This example demonstrates the use of ANSI escape codes for terminal coloring, including bold text, reset codes, and specific colors for branding and command names. ```bash echo -e "\033[1mStart \033[38;5;88mNode-RED\033[0m" ``` -------------------------------- ### Install Node-RED on RPM Systems with Firewall Source: https://github.com/node-red/linux-installers/blob/master/_autodocs/INDEX.md Installs and updates Node-RED on RPM-based systems (Fedora/CentOS), opening the necessary port in the firewall. The script automatically adds port 1880 to the firewall's public zone. ```bash # Fedora/CentOS with firewall bash update-nodejs-and-nodered \ --nodered-user=nodered \ --open-firewall \ --confirm-install # Port 1880 added to firewall public zone ```