Registry / devops / node-red-contrib-config

node-red-contrib-config

JSON →
library1.2.2jsnpmunverified

node-red-contrib-config is a Node-RED node designed for managing and setting flow and global context variables. It allows developers to define configuration values in a centralized location within their Node-RED flows and apply them either during the Node-RED startup phase (initialization) or dynamically at runtime through messages or manual triggers. This enables robust management of application state and parameters, supporting scenarios where configuration needs to be altered programmatically or manually without redeploying entire flows. The current stable version is 1.2.2, with releases occurring periodically based on feature enhancements and bug fixes rather than a strict schedule. Its key differentiator lies in providing a dedicated, visual mechanism within the Node-RED environment for both initial and dynamic context variable management, serving as an important tool for maintaining consistent application settings across complex deployments.

npm install node-red-contrib-config
INSTALL
IMPORT
SIG · NODE-RED-CONTRIB-C
N
node-red-contrib-config
devopsjavascriptv1.2.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

node-red-contrib-config (npm installation)
npm install node-red-contrib-config
import { configNode } from 'node-red-contrib-config'
This package provides a custom node for Node-RED. It is installed into the Node-RED runtime environment, not imported into JavaScript code directly. Installation can be done via npm in your Node-RED user directory (~/.node-red) or through the Node-RED 'Manage Palette' interface.
Config Node (Node-RED Palette)
Search for 'config' in the Node-RED palette and drag the node to your flow.
Once installed, the 'config' node appears in the Node-RED editor's palette, typically categorized under 'storage' or 'function', allowing you to graphically add it to your flows and configure its properties.
Node-RED Context Properties
msg.context.global.get('myVar'); flow.get('myOtherVar');
global.myVar; flow.myOtherVar;
While this `config` node *sets* context variables, access within other nodes typically uses `flow.get()` or `global.get()`. Direct property access (`global.myVar`) is deprecated in newer Node-RED versions and can lead to issues with context store configuration.

This Node-RED flow demonstrates how to use the `config` node to set a global context variable ('PC_Stability') at startup, manually via node buttons, and programmatically via incoming messages. Debug nodes display the updated context value.

[{"id":"b6833c82.c22a7","type":"config","z":"f27157a9.390a88","name":"PC_Stability (Startup)","property":"global.PC_Stability","value":"OK (startup)","valueType":"str","active":true,"x":170,"y":100,"wires":[["71a7b11c.e3f324"]]},{"id":"b22989c4.954aa8","type":"config","z":"f27157a9.390a88","name":"PC_Stability (Manual)","property":"global.PC_Stability","value":"Warning (manual)","valueType":"str","active":false,"x":170,"y":180,"wires":[["71a7b11c.e3f324"]]},{"id":"98c8c257.067c28","type":"inject","z":"f27157a9.390a88","name":"Set OK (msg)","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":260,"wires":[["b6833c82.c22a7"]]},{"id":"86d6d45e.d875a","type":"inject","z":"f27157a9.390a88","name":"Set Warning (msg)","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":320,"wires":[["b22989c4.954aa8"]]},{"id":"71a7b11c.e3f324","type":"debug","z":"f27157a9.390a88","name":"Debug PC_Stability","topic":"","preserveContext":false,"x":470,"y":180,"wires":[]},{"id":"e3f324","type":"function","z":"f27157a9.390a88","name":"Show global.PC_Stability","func":"msg.payload = global.get('PC_Stability');\nreturn msg;","outputs":1,"noerr":0,"x":490,"y":260,"wires":[["71a7b11c.e3f324"]]},{"id":"f27157a9.390a88","type":"tab","label":"Config Node Example","disabled":false,"info":""}]
Debug
Known issues
gotchaNode-RED context variables have different scopes (flow and global). Ensure you select the correct 'Property' field prefix (e.g., `flow.myVar` or `global.myVar`) to match your intended scope. Misconfigured scopes can lead to variables not being accessible where expected.
fix
Always explicitly define context scope (e.g., `global.yourKey` for global, `flow.yourKey` for flow-specific) in the 'Property' field of the `config` node.
affects: >=1.0.1
gotchaThe persistence of global and flow context variables depends on your Node-RED `settings.js` configuration. If not configured for file or other persistent storage, context values will be reset on Node-RED restarts, overriding any values set by the 'config' node's 'Active' (startup) feature. This node sets the value, but doesn't manage the context store's persistence.
fix
Review and configure your Node-RED `settings.js` for desired context persistence, especially if relying on 'Active' startup configuration across restarts. See Node-RED documentation on 'Context' and 'Storage'.
affects: >=1.0.1
gotchaWhen the 'config' node applies configuration via an incoming message or button press, it emits a message with a 100ms delay. If subsequent nodes immediately depend on the updated context value in the same flow path, they might receive the old value if they process faster than this delay or without a preceding delay node.
fix
If immediate usage of newly applied context values is critical in the same flow path, consider adding a small `delay` node (e.g., 150ms) after the 'config' node's output to ensure context is updated before consumption by downstream nodes.
affects: >=1.0.1
deprecatedDirect access to context variables (e.g., `global.myVar` or `flow.myVar`) within function nodes or other parts of Node-RED is deprecated. Newer Node-RED versions recommend using the `context.get()` and `context.set()` methods for better compatibility with different context storage backends and future-proofing.
fix
Always use `global.get('myVar')`, `global.set('myVar', value)`, `flow.get('myVar')`, or `flow.set('myVar', value)` to access and modify context variables programmatically within function nodes.
affects: >=1.0.1
Errors
Common errors & fixes
Error: Cannot find module 'node-red-contrib-config' or 'TypeError: Cannot read properties of undefined (reading 'nodes')' related to 'node-red-contrib-config'
The package was not correctly installed into the Node-RED environment or Node-RED was not restarted after installation.
fix
Ensure you are in the Node-RED user directory (e.g., `~/.node-red`) and run `npm install node-red-contrib-config`, then restart Node-RED to load the new nodes into the palette.
Flow or global context variable not updated or accessible after configuration application.
Incorrect scope (flow vs. global) specified in the 'Property' field, or a timing issue where other nodes access the variable before it's updated, or the 'Active' checkbox is not enabled for startup configuration.
fix
Verify the 'Property' field uses `global.yourKey` or `flow.yourKey` correctly. For timing, consider adding a short `delay` node after the 'config' node's output. Ensure the 'Active' checkbox is ticked if you expect configuration to apply at startup.
Configuration set at startup (using 'Active' checkbox) is lost after Node-RED restarts.
Node-RED's context storage is not configured for persistence (e.g., using default memory-based storage, which is ephemeral).
fix
Edit your Node-RED `settings.js` file and configure `contextStorage` to use a persistent store like `localfilesystem` or another suitable option for your environment.
Upgrade
Version history
1.2.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources