Can't access environment variables in subflow (Node-RED)

I am making a subflow that will set a message property but it uses an environment variable from the subflow to determine if it should set a message, but every time I call env.get() I get this error: “TypeError: Object.hasOwn is not a function”

I am running Node-RED version 3.1.7, any help would be greatly appreciated!

image

image

// Sets msg.isCombined = true IF combined inlet is open
// Sets msg.apm to the APM with the open inlet

const GAS_ANALYZER_NAME = env.get("GAS_ANALYZER_NAME"); // Causes error

for (let i = 0; i < msg.digitalOutputs.length; i++) {
    const digitalOutput = msg.digitalOutputs[i];

    if (digitalOutput.name.includes(GAS_ANALYZER_NAME))
        if (digitalOutput.value) {
            const tagParts = digitalOutput.name.split("_");
            const apmParts = tagParts[1].split("APM");

            if (apmParts.length == 2)
                msg.apm = parseInt(apmParts[1]); // Get APM ID
            else
                msg.isCombined = true; // Using combined inlet
            break;
        }
}

return msg;

I think is this the same issue as described here?

1 Like

Thank you! I did not realize there was already a post on this, it appears to be the same exact issue I am having