Just can't get external modules to load properly on function node

Hello,

I'm running Node-Red version 1.3.9 using Docker. I am binding the /data directory to a local folder. No problems there. I've edited settings, and installed custom nodes through the palette manager, and everything is working.

However, when I add any module to the setup tab of a function node, I can't get it to find the installed package.

I confirm that the package is correctly added to the packages.json file, and the files are downloaded and present in the /data/node_modules folder. It's almost like they are just being ignored.

I'm hoping I'm just missing something obvious.

Thank you for any kind of troubleshooting advice you can offer.

Welcome to the forum @sosukeinu

Please select the Function node and Export it, and paste it here so we can look at what you have done.

What error are you seeing and where?

?? A bit old ??

@krambriw is right, that is a very old version. Please upgrade to to the latest (3.1.9) and see if that fixes it. If not then do as I suggested earlier.

Okay,....first of all, I'm an idiot, I swapped the numbers around in the version. I AM on 3.1.9, not 1.3.9. smacks forehead. Also, I kept digging. I think the issue is with the module I'm trying to load. It does not include a "main", nor "exports" in it's packages.json. I'm thinking that might be the issue.

Here is the flow so you can confirm that I'm not crazy.

Thank you very much for your help.

[
    {
        "id": "350783714c1c3545",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "639c99602972cf3c",
        "type": "function",
        "z": "350783714c1c3545",
        "name": "GeoJSON Circle from 2 Points",
        "func": "node.warn(\"loaded\")\nconst range = (start, stop, step = 1) =>\n  Array(Math.ceil((stop - start) / step)).fill(start).map((x, y) => x + y * step)\n\nif ('circle' in msg.payload) {\n    const angles = range(0, 360, 10)\n    const gc = msg.payload.circle\n    const centerpoint = [gc[0].lat, gc[0].lon]\n    const outerpoint = [gc[1].lat, gc[1].lon]\n    const distance = [centerpoint, outerpoint]\n\n\n  msg.debug = {\n    \"const angles\": angles,\n    \"const gc\": gc,\n    \"const centerpoint\": centerpoint,\n    \"const distance\": distance\n  }\n}\n\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [
            {
                "var": "geodesy",
                "module": "geodesy"
            }
        ],
        "x": 630,
        "y": 460,
        "wires": [
            []
        ]
    },
    {
        "id": "6802b087b5bca1d5",
        "type": "inject",
        "z": "350783714c1c3545",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 300,
        "y": 460,
        "wires": [
            [
                "639c99602972cf3c"
            ]
        ]
    }
]
1 Like

I think you may well be correct, I see the same problem. It needs someone with more knowledge than myself of how this all works to comment...

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.