### Configure Node-RED to start automatically with PM2 Source: https://github.com/node-red/node-red.github.io/blob/main/docs/getting-started/aws.md Installs PM2, starts Node-RED as a service, saves the current process list, and sets up PM2 to start on system boot. Follow the output of 'pm2 startup' for further instructions. ```bash sudo npm install -g pm2 ``` ```bash pm2 start `which node-red` -- -v ``` ```bash pm2 save ``` ```bash pm2 startup ``` -------------------------------- ### Install Jekyll Dependencies and Serve Site Source: https://github.com/node-red/node-red.github.io/blob/main/README.md Install necessary dependencies using Bundler and start the Jekyll development server to preview the site locally. Ensure Jekyll is installed first. ```bash cd node-red.github.io bundle install bundle exec jekyll serve -w ``` -------------------------------- ### Confirm npm Installation Source: https://github.com/node-red/node-red.github.io/blob/main/docs/getting-started/local.md Example output confirming a successful Node-RED installation via npm. ```bash + node-red@4.1.7 added 227 packages in 13s found 0 vulnerabilities ``` -------------------------------- ### Install and Configure PM2 for Auto-Start Source: https://github.com/node-red/node-red.github.io/blob/main/docs/getting-started/azure.md Installs PM2, a process manager, to ensure Node-RED starts automatically on instance restart and saves the current process list. ```bash sudo npm install -g pm2 pm2 start `which node-red` -- -v pm2 save pm2 startup ``` -------------------------------- ### Install Node-RED on Android Source: https://github.com/node-red/node-red.github.io/blob/main/docs/getting-started/android.md Install necessary packages and Node-RED on Termux. After installation, run 'node-red' to start the server. ```bash apt update apt upgrade apt install coreutils nano nodejs npm i -g node-red node-red ``` -------------------------------- ### Verify Node.js and npm Installation (cmd) Source: https://github.com/node-red/node-red.github.io/wiki/Windows-Installation Run this command in the Windows command prompt (cmd) to confirm Node.js and npm are installed correctly after the initial Node.js setup. ```cmd node --version && npm --version ``` -------------------------------- ### start Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/modules/v/1.3/@node-red_runtime.html Starts the Node-RED runtime. ```APIDOC ## start ( ) ### Description Starts the Node-RED runtime. ``` -------------------------------- ### Install Node-RED with Snap Source: https://github.com/node-red/node-red.github.io/blob/main/docs/getting-started/local.md Installs Node-RED using Snap. Note that Snap installations have limitations regarding system access and compilation. ```bash sudo snap install node-red ``` -------------------------------- ### Verify Node.js and npm Installation (PowerShell) Source: https://github.com/node-red/node-red.github.io/wiki/Windows-Installation Run this command in PowerShell to confirm Node.js and npm are installed correctly after the initial Node.js setup. ```powershell node --version; npm --version ``` -------------------------------- ### preInstall Hook Example Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/hooks/install/index.md Logs information about the module before it is installed. This hook can modify the InstallEvent to alter npm arguments. ```javascript RED.hooks.add("preInstall", (installEvent) => { console.log(`About to install ${installEvent.module}@${installEvent.version}`); }); ``` -------------------------------- ### Specify Settings File via Command Line Source: https://github.com/node-red/node-red.github.io/blob/main/_posts/2013-12-21-version-0-5-0-released.md Use the `--settings` or `-s` flag to point to the location of your settings file when starting Node-RED. This is useful for managing user data outside the install directory. ```bash $ node red.js --settings /home/nol/.node-red/settings.js ``` -------------------------------- ### Get Nodes (JSON Response) Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/admin/methods/get/nodes/index.md Example of the JSON response when requesting a list of installed nodes. This format provides structured data about each node set. ```json [ { "id": "node-red/sentiment", "name": "sentiment", "types": [ "sentiment" ], "enabled": true, "module": "node-red" "version": "0.10.6" } ] ``` -------------------------------- ### postInstall Hook Example for Rebuilding Modules Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/hooks/install/index.md Rebuilds an npm module after installation, commonly used in Electron environments. The done callback must be invoked to signal completion. ```javascript RED.hooks.add("postInstall", (installEvent, done) => { child_process.exec("npm run rebuild " + installEvent.module, {cwd: installEvent.dir}, (err, stdout, stderr) => { done(); } ); }); ``` -------------------------------- ### Node Installation Instructions Source: https://github.com/node-red/node-red.github.io/wiki/Node-Guideline-Contents Provides the npm command to install a Node-RED node. This is typically placed in the README file. ```markdown node-red-contrib-swagger-petstore ===================== Node-RED node for swagger petstore Install ------- Run the following command in your Node-RED user directory - typically `~/.node-red` npm install node-red-contrib-swagger-petstore ``` -------------------------------- ### Initialize Context on Start Source: https://github.com/node-red/node-red.github.io/blob/main/docs/user-guide/writing-functions.md Use the `On Start` tab to initialize context variables when the Function node starts. This code runs once on node startup. ```javascript if (context.get("counter") === undefined) { context.set("counter", 0) } ``` -------------------------------- ### start() Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/modules/v/1.3/@node-red_runtime.html Starts the Node-RED runtime. The promise resolves when the runtime has been initialized, but not necessarily when all flows are running. ```APIDOC ## start() ### Description Starts the Node-RED runtime. The promise resolves when the runtime has been initialized, but not necessarily when all flows are running. ### Method Not applicable (JavaScript method) ### Endpoint Not applicable (JavaScript method) ### Returns: Type: `Promise` * resolves when the runtime is started. This does not mean the flows will be running as they are started asynchronously. ``` -------------------------------- ### Install Python and ML Dependencies in Dockerfile.debian Source: https://github.com/node-red/node-red.github.io/blob/main/docs/getting-started/docker-custom.md Example Dockerfile snippet for `Dockerfile.debian` showing how to install build tools, Python 3, pip, NumPy, Pandas, and TensorFlow. This integrates dependencies directly into the build process. ```docker RUN chown -R node-red:root /usr/src/node-red && \ apt-get update && apt-get install -y build-essential python-dev python3 \ python3-pip python3-numpy python3-pandas && \ pip install scikit-learn tensorflow && \ rm -r /tmp/* USER node-red ``` -------------------------------- ### start Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/modules/v/1.3/@node-red_editor-api.html Starts the Node-RED Editor API module, preparing it to handle requests. ```APIDOC ## start() ### Description Start the module. ### Returns - **Promise** - resolves when the application is ready to handle requests ``` -------------------------------- ### Install RPi.GPIO Python Library Source: https://github.com/node-red/node-red.github.io/blob/main/_posts/2015-02-08-version-0-10-1-released.md Installs the necessary Python development files and the RPi.GPIO library. Ensure this is version 0.5.8 or newer for interrupt-driven input detection. ```bash sudo apt-get update sudo apt-get install python-dev python-rpi.gpio ``` -------------------------------- ### Start Node-RED Service Source: https://github.com/node-red/node-red.github.io/blob/main/docs/getting-started/beaglebone.md Command to start the Node-RED service. ```bash sudo service node-red start ``` -------------------------------- ### Verify Node.js and npm Installation Source: https://github.com/node-red/node-red.github.io/blob/main/docs/getting-started/windows.md Run this command in a command prompt or PowerShell to ensure Node.js and npm are installed correctly after installation. Re-open your terminal if you had it open during installation. ```powershell node --version; npm --version ``` ```cmd node --version && npm --version ``` -------------------------------- ### Start Node-RED Docker Container Source: https://github.com/node-red/node-red.github.io/blob/main/docs/getting-started/docker.md Start a previously created and stopped Node-RED Docker container. ```bash docker start mynodered ``` -------------------------------- ### Run Node-RED Source: https://github.com/node-red/node-red.github.io/blob/main/docs/getting-started/development.md Starts Node-RED using the npm start command. This is the basic command to run the application. ```bash npm start ``` -------------------------------- ### Run Node-RED from Command Prompt Source: https://github.com/node-red/node-red.github.io/blob/main/docs/getting-started/windows.md Execute this command in a Windows command prompt to start Node-RED. Keep the terminal open to maintain the running process. This command assumes Node-RED is installed globally via npm. ```bash C:>node-red ``` -------------------------------- ### Install Node-RED Globally Source: https://github.com/node-red/node-red.github.io/wiki/Windows-Installation Execute this command in your command prompt to install Node-RED as a global module, making the 'node-red' command available system-wide. ```bash npm install -g --unsafe-perm node-red ``` -------------------------------- ### List Installed Nodes Source: https://github.com/node-red/node-red.github.io/blob/main/docs/user-guide/node-red-admin.md View a list of all Node-RED nodes currently installed in the target instance. ```bash node-red-admin list ``` -------------------------------- ### Install Node-RED Dependencies from Release Source: https://github.com/node-red/node-red.github.io/wiki/Installation After downloading and extracting a Node-RED release, navigate to the extracted folder and run this command to install production dependencies. ```bash npm install --production ``` -------------------------------- ### Install Node-RED Arduino Nodes Source: https://github.com/node-red/node-red.github.io/blob/main/docs/faq/interacting-with-arduino.md Install the necessary Node-RED nodes for Arduino interaction. Ensure you are in the Node-RED user directory. ```bash cd ~/.node-red npm install node-red-node-arduino ``` -------------------------------- ### Install Node.js and Node-RED Source: https://github.com/node-red/node-red.github.io/blob/main/docs/getting-started/azure.md Installs Node.js version 12.x and Node-RED globally. This is required before running Node-RED. ```bash curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - sudo apt-get install -y nodejs build-essential sudo npm install -g node-red ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/node-red/node-red.github.io/blob/main/docs/getting-started/development.md Installs all necessary project dependencies using npm ci for a clean and reproducible environment. ```bash npm ci ``` -------------------------------- ### Example Response Body Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/admin/methods/post/auth/token/index.md This is an example of a successful response body when exchanging credentials for an access token. ```json { "access_token": "A_SECRET_TOKEN", "expires_in":604800, "token_type": "Bearer" } ``` -------------------------------- ### Install Termux API Add-on Source: https://github.com/node-red/node-red.github.io/blob/main/docs/getting-started/android.md Install the Termux:API add-on within Termux to enable access to device hardware and features. ```bash apt install termux-api ``` -------------------------------- ### Get Flow State Response Example Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/admin/methods/get/flows/state/index.md This is an example of the JSON response when successfully retrieving the current state of the Node-RED flows. The `state` field indicates whether the runtime is 'start' or 'stop'. ```json { "state": "stop" } ``` -------------------------------- ### Install node-red-admin Globally Source: https://github.com/node-red/node-red.github.io/blob/main/docs/user-guide/node-red-admin.md Install the node-red-admin tool as a global module using npm. Sudo may be required on Linux/OS X, or run as Administrator on Windows. ```bash npm install -g node-red-admin ``` -------------------------------- ### Configure Memory and Custom Context Stores Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/context/index.md Example showing how to configure both the default memory store and a custom store loaded via require. ```javascript contextStorage: { default: { module:"memory", }, custom: { module:require("my-custom-store") } } ``` -------------------------------- ### Metric Log Output Examples Source: https://github.com/node-red/node-red.github.io/blob/main/docs/user-guide/runtime/logging.md Examples of log output when metrics are enabled, showing node events and memory usage. ```log 9 Mar 13:57:53 - [metric] {"level":99,"nodeid":"8bd04b10.813f58","event":"node.inject.receive","msgid":"86c8212c.4ef45","timestamp":1489067873391} ``` ```log 9 Mar 13:57:53 - [metric] {"level":99,"nodeid":"8bd04b10.813f58","event":"node.inject.send","msgid":"86c8212c.4ef45","timestamp":1489067873392} ``` ```log 9 Mar 13:57:53 - [metric] {"level":99,"nodeid":"4146d01.5707f3","event":"node.debug.receive","msgid":"86c8212c.4ef45","timestamp":1489067873393} ``` ```log 9 Mar 13:56:24 - [metric] {"level":99,"event":"runtime.memory.rss","value":97517568,"timestamp":1489067784815} ``` ```log 9 Mar 13:56:24 - [metric] {"level":99,"event":"runtime.memory.heapTotal","value":81846272,"timestamp":1489067784817} ``` ```log 9 Mar 13:56:24 - [metric] {"level":99,"event":"runtime.memory.heapUsed","value":59267432,"timestamp":1489067784817} ``` -------------------------------- ### initialiseProject Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/modules/v/1.3/@node-red_runtime_projects.html Initializes a new, empty project. ```APIDOC ## initialiseProject(opts) ### Description Initialises an empty project. ### Method Not applicable (JavaScript function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters `opts` (Object) - Options for the request. - `user` ([User](global.html#User)) - The user calling the API. - `id` (String) - The ID of the project to initialise. - `project` (Object) - The project information. - `req` (Object) - The request to log (optional). ### Returns Type: `Promise.` * Resolves when complete. ``` -------------------------------- ### Storage.init(settings) Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/storage/methods/index.md Initializes the storage system with the provided runtime settings. It returns a promise that resolves once the initialization is complete. ```APIDOC ## Storage.init(settings) ### Description Initialise the storage system. ### Parameters #### Path Parameters * None #### Query Parameters * None #### Request Body * None ### Method *Not applicable (SDK method)* ### Endpoint *Not applicable (SDK method)* ### Parameters #### Arguments - **settings** (object) - The runtime settings. ### Returns A promise that resolves when the storage system is initialised. ``` -------------------------------- ### Flow Configuration Object Example Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/admin/methods/post/flow/index.md This is an example of the minimum required JSON object to define a new flow. It includes an ID, label, and empty arrays for nodes and configurations. ```json { "id": "91ad451.f6e52b8", "label": "Sheet 1", "nodes": [ ], "configs": [ ] } ``` -------------------------------- ### getNodeExampleFlowPath Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/modules/v/1.3/@node-red_registry.html Gets the file path for a node's example flow. ```APIDOC ## getNodeExampleFlowPath(...) ### Description Gets the file path for a node's example flow. ### Method (Not specified, likely internal function call) ### Endpoint (Not applicable, internal function) ### Parameters (Parameters not explicitly detailed in the source) ### Request Example (Not applicable) ### Response (Response details not explicitly detailed in the source) ``` -------------------------------- ### Enable Node-RED Auto-start on Boot Source: https://github.com/node-red/node-red.github.io/blob/main/docs/getting-started/beaglebone.md Use this systemctl command to configure Node-RED to start automatically when the BeagleBone boots. ```bash sudo systemctl enable node-red.service ``` -------------------------------- ### GET /nodes Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/admin/methods/index.md Retrieves a list of all installed node modules within the Node-RED environment. ```APIDOC ## GET /nodes ### Description Get a list of the installed nodes. ### Method GET ### Endpoint /nodes ``` -------------------------------- ### init(runtime) Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/modules/v/1.3/@node-red_registry.html Initializes the registry with a reference to the runtime object. This is a crucial setup step for the registry's operation. ```APIDOC ## init(runtime) ### Description Initialise the registry with a reference to a runtime object ### Parameters: #### Path Parameters - **runtime** (Object) - Required - a runtime object ``` -------------------------------- ### init Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/modules/v/1.3/@node-red_runtime.html Initializes the Node-RED runtime with provided settings, server, and admin API. ```APIDOC ## init ( settings, server, adminApi ) ### Description Initializes the Node-RED runtime with the given settings, server instance, and admin API. ### Parameters - **settings** - The runtime settings object. - **server** - The HTTP server instance. - **adminApi** - The admin API object. ``` -------------------------------- ### Re-install a Specific Node Source: https://github.com/node-red/node-red.github.io/wiki/Upgrading Install the latest version of a specific node, for example, 'foo'. ```bash npm install foo ``` -------------------------------- ### Configure Node-RED Startup with Task Scheduler Source: https://github.com/node-red/node-red.github.io/wiki/Windows-Installation This is the command to be used in the 'Start a program' action within Windows Task Scheduler to launch Node-RED at system startup. Replace `` with your actual username. It's recommended to use `node-red.cmd` for better compatibility with Windows environments. ```batch C:\Users\\AppData\Roaming\npm\node-red.cmd ``` -------------------------------- ### Get Node Module Info Response Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/admin/methods/get/nodes/module/index.md Example JSON response body when successfully retrieving information for a node module. ```json { "name": "node-red-node-suncalc", "version": "0.0.6", "nodes": [ { "id": "node-red-node-suncalc/suncalc", "name": "suncalc", "types": [ "sunrise" ], "enabled": true, "module": "node-red-node-suncalc", "version": "0.0.6" } ] } ``` -------------------------------- ### Run Node-RED with Docker Source: https://github.com/node-red/node-red.github.io/blob/main/docs/getting-started/local.md Starts a Node-RED container using Docker, mapping port 1880. For more details, refer to the Docker guide. ```bash docker run -it -p 1880:1880 --name mynodered nodered/node-red ``` -------------------------------- ### Get Flows State Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/admin/methods/get/flows/state/index.md Retrieves the current runtime state of the Node-RED flows. This endpoint requires an Authorization header if authentication is enabled. The response indicates whether the flows are currently 'start' or 'stop'. ```APIDOC ## GET /flows/state ### Description Get the current runtime state of flows. Note that runtime state of flows is available only if `runtimeState` value is set to `enabled: true` in the `settings.js` file. ### Headers - **Authorization** (`Bearer [token]`) - Required if authentication is enabled ### Response #### Success Response (200) - **state** (`string`) - runtime state of the flows. Can be either `start` or `stop` #### Response Example ```json { "state": "stop" } ``` #### Error Response (401) - **Not authorized** ``` -------------------------------- ### Enable Node-RED Service to Autostart on Boot Source: https://github.com/node-red/node-red.github.io/blob/main/docs/getting-started/raspberrypi.md Configures the Node-RED service to automatically start when the Raspberry Pi boots up. ```bash sudo systemctl enable nodered.service ``` -------------------------------- ### Get Library Entry Example Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/storage/methods/index.md Illustrates the structure of a directory listing returned by Storage.getLibraryEntry when the name argument represents a logical directory. Each item is either a subdirectory name or an object with entry metadata. ```javascript [ 'directory1', 'directory2', { fn: 'File-1.js', outputs: 3 }, { fn: 'File-2.js', outputs: 1 }, { fn: 'File-3.js', outputs: 2 } ] ``` -------------------------------- ### Get Object Property Example Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/modules/v/1.3/@node-red_util_util.html Demonstrates how to retrieve a nested property from an object using a string expression. Handles cases where properties exist, do not exist, or when accessing properties of non-existent parent objects. ```javascript const obj = { "pet": { "type": "cat" } }; // Example usage: // obj.pet.type will return "cat" // obj.pet.name will return undefined // obj.car will return undefined // obj.car.type will throw an Error (as car does not exist) ``` -------------------------------- ### Install Web Nodes Source: https://github.com/node-red/node-red.github.io/blob/main/_posts/2014-09-24-version-0-9-0-released.md Use this command to add the new web nodes to your Node-RED palette. ```bash $ npm install node-red-node-web-nodes ``` -------------------------------- ### Initialize npm Package Source: https://github.com/node-red/node-red.github.io/blob/main/docs/creating-nodes/subflow-modules.md Use 'npm init' to create a package.json file for your subflow module. Provide answers that match your subflow's metadata. ```bash npm init ``` -------------------------------- ### GET /nodes Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/admin/methods/get/nodes/index.md Retrieves a list of installed nodes. The response format depends on the Accept header. JSON response includes detailed Node Set objects, while HTML response provides a single HTML content. ```APIDOC ## GET /nodes ### Description Get a list of the installed nodes. Requires permission: `nodes.read`. ### Method GET ### Endpoint /nodes ### Headers - `Accept` (string) - Required - `application/json` or `text/html` - `Authorization` (string) - Required - `Bearer [token]` ### Response #### Success Response (200) - **Content** (Node Set array or HTML) - Description depends on the `Accept` header. - If `Accept: application/json`, returns an array of Node Set objects. - If `Accept: text/html`, returns HTML content for all installed nodes. #### Response Example (Accept: application/json) ```json [ { "id": "node-red/sentiment", "name": "sentiment", "types": [ "sentiment" ], "enabled": true, "module": "node-red", "version": "0.10.6" } ] ``` #### Error Response (401) - **None** - Not authorized ``` -------------------------------- ### Get Runtime Settings Response Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/admin/methods/get/settings/index.md This is an example of the JSON response received when successfully retrieving Node-RED runtime settings. It includes the HTTP node root path, runtime version, and user information if authentication is enabled. ```json { "httpNodeRoot": "/", "version": "0.X.Y", "user": { "username": "admin", "permissions": "*" } } ``` -------------------------------- ### Configure Multiple Static Directories Source: https://github.com/node-red/node-red.github.io/blob/main/docs/user-guide/runtime/configuration.md Example of configuring multiple static directories with custom options for path, root URL, middleware, and CORS. ```javascript httpStatic: [ { path: '/opt/static/', root: '/private/', middleware: myCustomHttpMiddleware, cors: { } } ] ``` -------------------------------- ### Minimal Node-RED Embedding in Express.js Source: https://github.com/node-red/node-red.github.io/blob/main/docs/user-guide/runtime/embedding.md This snippet demonstrates the basic setup for embedding the Node-RED runtime within an Express.js application. It initializes the runtime with custom settings and starts the server. Ensure Node-RED and any necessary node dependencies are added to your package.json. ```javascript var http = require('http'); var express = require("express"); var RED = require("node-red"); // Create an Express app var app = express(); // Add a simple route for static content served from 'public' app.use("/",express.static("public")); // Create a server var server = http.createServer(app); // Create the settings object - see default settings.js file for other options var settings = { httpAdminRoot:"/red", httpNodeRoot: "/api", userDir:"/home/nol/.nodered/", functionGlobalContext: { } // enables global context }; // Initialise the runtime with a server and settings RED.init(server,settings); // Serve the editor UI from /red app.use(settings.httpAdminRoot,RED.httpAdmin); // Serve the http nodes UI from /api app.use(settings.httpNodeRoot,RED.httpNode); server.listen(8000); // Start the runtime RED.start(); ``` -------------------------------- ### init Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/modules/v/1.3/@node-red_registry.html Initializes the node registry. ```APIDOC ## init(...) ### Description Initializes the node registry. ### Method (Not specified, likely internal function call) ### Endpoint (Not applicable, internal function) ### Parameters (Parameters not explicitly detailed in the source) ### Request Example (Not applicable) ### Response (Response details not explicitly detailed in the source) ``` -------------------------------- ### Configure Default Memory Context Store Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/context/index.md Example of configuring the default context storage to use the memory-based implementation with custom options. ```javascript contextStorage: { default: { module:"memory", config: { customOption: 'value' } } } ``` -------------------------------- ### Example package.json for a Node-RED Module Source: https://github.com/node-red/node-red.github.io/blob/main/docs/creating-nodes/packaging.md This is a typical `package.json` structure for a Node-RED module. It includes the module name, version, description, dependencies, keywords, and the crucial `node-red` property that specifies the nodes to be loaded. ```json { "name" : "@myScope/node-red-sample", "version" : "0.0.1", "description" : "A sample node for Node-RED", "dependencies": { }, "keywords": [ "node-red" ], "node-red" : { "nodes": { "sample": "sample/sample.js" } } } ``` -------------------------------- ### Install Node Module Locally Source: https://github.com/node-red/node-red.github.io/blob/main/docs/creating-nodes/first-node.md Use npm install to link your local node module into a Node-RED installation for development. ```bash cd ~/.node-red npm install ~/dev/node-red-contrib-example-lower-case ``` ```bash cd C:\Users\my_name\.node_red npm install C:\Users\my_name\Documents\GitHub\node-red-contrib-example-lower-case ``` -------------------------------- ### Build and Run Node-RED from GitHub Clone Source: https://github.com/node-red/node-red.github.io/wiki/Installation After installing grunt-cli and dependencies from a GitHub clone, use these commands to build the application and then run it. ```bash grunt build node red ``` -------------------------------- ### Install BeagleBone Specific Nodes Source: https://github.com/node-red/node-red.github.io/blob/main/docs/getting-started/beaglebone.md Install BeagleBone I/O specific nodes using npm. This command installs `beaglebone-io`, `johnny-five`, and `node-red-contrib-gpio` globally. ```bash sudo npm install -g beaglebone-io johnny-five node-red-contrib-gpio ``` -------------------------------- ### Install Node Module via npm Source: https://github.com/node-red/node-red.github.io/blob/main/docs/user-guide/runtime/adding-nodes.md Use this command to install a node module from the command-line. Ensure you are in your Node-RED user data directory. Restart Node-RED after installation. ```bash npm install ``` -------------------------------- ### GET /flows/state Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/admin/methods/index.md Gets the current runtime state of the active flow. ```APIDOC ## GET /flows/state ### Description Get the active flow's runtime state. ### Method GET ### Endpoint /flows/state ``` -------------------------------- ### init Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/modules/v/1.3/@node-red_util.html Initializes the Node-RED utility module. ```APIDOC ## init(settings) ### Description Initialises the utility module with the runtime settings. ### Parameters * **settings** (Object) - The runtime settings object. ``` -------------------------------- ### Node-RED Command-Line Options Source: https://github.com/node-red/node-red.github.io/blob/main/_posts/2014-04-16-version-0-7-0-released.md Displays the available command-line options for running Node-RED. Use -v for verbose output or -? for help. ```bash $ node red.js -? Usage: node red.js [-v] [-?] [--settings settings.js] [flows.json] Options: -s, --settings FILE use specified settings file -v enable verbose output -?, --help show usage ``` -------------------------------- ### Install Node Module Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/admin/methods/post/nodes/index.md Installs a new node module. This can be done by specifying the module name for installation from an npm repository or by uploading a tgz package. Requires 'nodes.write' permission. ```APIDOC ## POST /nodes ### Description Installs a new node module. This can be done by specifying the module name for installation from an npm repository or by uploading a tgz package. Requires 'nodes.write' permission. ### Method POST ### Endpoint /nodes ### Headers - `Authorization`: `Bearer [token]` - if authentication is enabled - `Content-type`: `application/json` - if installing from a npm repository - `Content-type`: `multipart/form-data` - if installing a tgz package ### Parameters #### Request Body **If installing from npm repository:** - `module` (string) - Required - The name of the node module to install from the npm repository, or a full path to a directory containing the node module. Note: this API does not support the full range of module specifiers used by npm such as `.tgz` files or version qualifiers. **If installing a tgz package:** - `tarball` (file) - Required - The tgz package file to upload. ### Request Example **From npm repository:** ```json { "module": "node-red-node-suncalc" } ``` **From tgz package:** ```shell curl -X POST http://localhost:1880/nodes -H "Content-Type: multipart/form-data" -F "tarball=@node-red-contrib-foo-1.0.3.tgz;type=application/x-compressed-tar;filename=node-red-contrib-foo-1.0.3.tgz" ``` ### Response #### Success Response (200) - A [Node Module](/docs/api/admin/types#node-module) object. #### Response Example ```json { "name": "node-red-node-suncalc", "version": "0.0.6", "nodes": [ { "id": "node-red-node-suncalc/suncalc", "name": "suncalc", "types": [ "sunrise" ], "enabled": true, "loaded": true, "module": "node-red-node-suncalc" } ] } ``` #### Error Response - `400` Bad request - `401` Not authorized - `404` Not found ``` -------------------------------- ### Run Node-RED with Arguments Source: https://github.com/node-red/node-red.github.io/blob/main/docs/getting-started/development.md Starts Node-RED and passes command-line arguments using the '--' separator. This allows for custom configurations. ```bash npm start -- ``` -------------------------------- ### Install Node-RED Module Source: https://github.com/node-red/node-red.github.io/blob/main/docs/user-guide/node-red-admin.md Install a Node-RED module from NPM into the target Node-RED instance. ```bash node-red-admin install ``` -------------------------------- ### Stop and Start Node-RED Container Source: https://github.com/node-red/node-red.github.io/blob/main/docs/getting-started/docker.md Commands to stop a running Node-RED container and then start it again. ```bash docker stop mynodered docker start mynodered ``` -------------------------------- ### Termux:Boot Startup Script for Node-RED Source: https://github.com/node-red/node-red.github.io/blob/main/docs/getting-started/android.md A sample startup script for Termux:Boot to autostart Node-RED. This script includes a wake lock to keep the device awake. ```sh #!/data/data/com.termux/files/usr/bin/sh termux-wake-lock node /data/data/com.termux/files/usr/bin/node-red ``` -------------------------------- ### init Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/modules/v/1.3/@node-red_util.html Initializes the util module with settings. This function is typically called internally by Node-RED. ```APIDOC ## init ( settings ) ### Description Initializes the util module with the provided settings object. ### Method `init` ### Parameters #### Path Parameters - **settings** (object) - Required - The Node-RED settings object. ``` -------------------------------- ### run(command, args, options, emit) Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/modules/v/1.3/@node-red_util_exec.html Executes a system command, optionally emitting stdout/stderr as 'event-log' events. It leverages `child_process.spawn` for execution and returns a Promise that resolves with the command's exit code, stdout, and stderr, or rejects if the command fails. ```APIDOC ## run(command, args, options, emit) ### Description Runs a system command with stdout/err being emitted as 'event-log' events on the @node-red/util/events handler. The main arguments to this function are the same as passed to `child_process.spawn`. ### Parameters #### Parameters - **command** (String) - The command to run. - **args** (Array) - Arguments for the command. - **options** (Object) - Options to pass to `child_process.spawn`. - **emit** (Boolean) - Whether to emit events to the event-log for each line of stdout/err. ### Returns - **Promise** - A promise that resolves (rc=0) or rejects (rc!=0) when the command completes. The value of the promise is an object of the form: { code: , stdout: , stderr: } ``` -------------------------------- ### installModule(module, version, url) Source: https://github.com/node-red/node-red.github.io/blob/main/docs/api/modules/v/1.3/@node-red_registry.html Installs a new Node.js module using npm, then adds it to the registry. It supports installing from a name, a version, or a URL, and can also accept a module tar file as a Buffer. ```APIDOC ## installModule(module, version, url) ### Description Installs a new node module using npm and then add to the registry ### Parameters: #### Path Parameters - **module** (String | Buffer) - Required - the name of the module to install, or a Buffer containing a module tar file - **version** (String) - Optional - the version of the module to install, default: `latest` - **url** (String) - Optional - a url to install the module from ### Returns: Type: `Promise.` A promise that resolves with the module information once it has been installed ``` -------------------------------- ### Install Node-RED Dashboard Node Source: https://github.com/node-red/node-red.github.io/blob/main/docs/getting-started/android.md Install additional Node-RED nodes, such as node-red-dashboard, within the Termux environment. ```bash cd ~/.node-red npm i node-red-dashboard ``` -------------------------------- ### Enable eMMC Flasher Script Source: https://github.com/node-red/node-red.github.io/blob/main/docs/getting-started/beaglebone.md Uncomment this line in `/boot/uEnv.txt` to enable the script for flashing the eMMC from an SD card image. ```bash cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh ```