Modify the settings.js file of the free nodered agent instance intalled locally

I am not able to locate the settings.js of the nodered agent installed through openflow 1.5 in a docker locally, to set functionGlobalContext. Writing Functions : Node-RED

Someone knows what is the path of that file, or what is the path in what I must create it?

I think I got it. I am going to explain here if someone want to do it:

// Go to the src directory (displayed in the image before) and edit the file with vi and save it
vi nodered_settings.ts

//Go back to /tmp directory and run:
npm run build

Restart the nodered container

hey
That is not possible using my docker images.
The reason is, I generate the nodered settings in code and load nodered with that object.

Can you explain the use case ? maybe there is an alternative way, or I could have a look into a way to allow this to be done using openflow

Good morning Allan.
I wanted to import an external module to be used inside a function node, more specifically the request module for http request handling.

var request = global.get('request');

At first I tried to import and it didn’t worked, because when I was calling the request function the node was throwing and exception the function wasn’t registered.
When I did what I described before, I was able to successfully import a module to be available on NodeRED.

This was my inclusion:

Thanks and regards

request is not a builtin module, but something you install separately using npm.
There for you can simply use a function node, and add it as a module on the “Setup tab”
image
This will include the module in the list of modules sent to the storage provider, and there for be handled just like a normal nodered module installed using the palette.

Here is an example workflow

[
    {
        "id": "ee942d121b0090ec",
        "type": "inject",
        "z": "562ba6bdfee8207a",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 160,
        "y": 1880,
        "wires": [
            [
                "96b01ebb5a465c7c"
            ]
        ]
    },
    {
        "id": "96b01ebb5a465c7c",
        "type": "function",
        "z": "562ba6bdfee8207a",
        "name": "",
        "func": "try {\n    figlet('OpenIAP', function(err, data) {\n        if (err) {\n            node.error(err);\n            return;\n        }\n        node.warn(data)\n    });\n} catch (err) {\n    node.error(err);\n}",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [
            {
                "var": "figlet",
                "module": "figlet"
            }
        ],
        "x": 320,
        "y": 1880,
        "wires": [
            [
                "2228445237a3544a"
            ]
        ]
    },
    {
        "id": "2228445237a3544a",
        "type": "debug",
        "z": "562ba6bdfee8207a",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 490,
        "y": 1880,
        "wires": []
    }
]
1 Like

Thanks so much for sharing this approach. We only need to install the module through npm and import it in the Setup tab of the function node. This is a more elegant way to import npm modules.

Regards!