Nodered saving context data in local filesystem

The official tutorial is

cd ~/.node-red/
sudo nano settings.js

Add the following code

    editorTheme: {
        menu: { "menu-item-help": {
            label: "Node-RED Pi Website",
            url: ""
        } },
        projects: {
            // To enable the Projects feature, set this value to true
            enabled: false,
            workflow: {
                // Set the default projects workflow mode.
                //  - manual - you must manually commit changes
                //  - auto - changes are automatically committed
                // This can be overridden per-user from the 'Git config'
                // section of 'User Settings' within the editor
                mode: "manual"
    }, //Remember to add ',' 
    contextStorage: {
        default: "memoryOnly",
        memoryOnly: { module: 'memory' },
        file: { module: 'localfilesystem' }

Variables saved in memory and localfilesystem are in fact different variables, they can have the same name. So when you save or get the variables, remember to specify which one you are pointing at.

This will store the variable storedInMemory in RAM.

flow.set("storedInMemory", true)
flow.set("storedInMemory", true, "default")
flow.set("storedInMemory", true, "memoryOnly")

And this will store the variable in localfilesystem. The context data will be stored under ~/.node-red/context/ by default.

flow.set("storedInMemory", false, "file")

Similar method to get the variables stored in localfilesystem

flow.get("storedInMemory", "file")

Leave a Reply

Your email address will not be published. Required fields are marked *