Problem in packaging the subflow

When I packaged the subflow, I followed the tutorial on the website(https://nodered.org/docs/creating-nodes/subflow-modules) and nothing seemed to change.
The result is that my package.json file didn't seem to work. "node-red": { "nodes": { "mqttout": "mqttout.js" } }
This is an example of MQTT sending data. Here are my related documents.
I refer to the blog https://discourse.nodered.org/t/how-to-package-node-red-subflows-into-a-dedicated-node-red-docker-container/61745

This is the mqttout.js file.

const fs = require("fs");
const path = require("path");

module.exports = function(RED) {
	const subflowFile = path.join(_dirname,"mqttout.json");
	const subflowContents = fs.readFileSync(subflowFile);
	const subflowJSON = JSON.parse(subflowContents);
	RED.nodes.registerSubflow(subflowJSON);
}

This is the mqttout.json.

{
   "id": "be86292c6d08f0da",
   "type": "subflow",
   "name": "Internal MQTT Out",
   "info": "",
   "category": "",
   "in": [
       {
           "x": 340,
           "y": 140,
           "wires": [
               {
                   "id": "b122f18e514d14f9"
               }
           ]
       }
   ],
   "out": [],
   "env": [],
   "meta": {},
   "color": "#C0DEED",
   "icon": "node-red/bridge.svg",
   "flow": [
       {
           "id": "b122f18e514d14f9",
           "type": "mqtt out",
           "z": "be86292c6d08f0da",
           "name": "Internal MQTT Broker",
           "topic": "",
           "qos": "",
           "retain": "",
           "respTopic": "",
           "contentType": "",
           "userProps": "",
           "correl": "",
           "expiry": "",
           "broker": "dbd22c0713b05ef6",
           "x": 560,
           "y": 140,
           "wires": []
       },
       {
           "id": "dbd22c0713b05ef6",
           "type": "mqtt-broker",
           "z": "be86292c6d08f0da",
           "name": "Internal MQTT Broker",
           "broker": "internal-mqtt-broker",
           "port": "1883",
           "clientid": "node-red-mqtt-internal-out",
           "autoConnect": true,
           "usetls": false,
           "protocolVersion": "4",
           "keepalive": "60",
           "cleansession": true,
           "birthTopic": "",
           "birthQos": "0",
           "birthPayload": "",
           "birthMsg": {},
           "closeTopic": "",
           "closeQos": "0",
           "closePayload": "",
           "closeMsg": {},
           "willTopic": "",
           "willQos": "0",
           "willPayload": "",
           "willMsg": {},
           "sessionExpiry": ""
       }
   ]
}

This is the package.json file .

{
    "name": "node-red-project",
    "description": "A Node-RED Project",
    "version": "0.0.1",
    "private": true,
    "dependencies": {
        "node-red-contrib-wait-paths": "~0.3.2"
    },
    "node-red": {
          "nodes": {
		"mqttout": "mqttout.js"
		}
    }
}

This is the json file export from the node-red.

[
    {
        "id": "be86292c6d08f0da",
        "type": "subflow",
        "name": "Internal MQTT Out no package",
        "info": "",
        "category": "",
        "in": [
            {
                "x": 340,
                "y": 140,
                "wires": [
                    {
                        "id": "b122f18e514d14f9"
                    }
                ]
            }
        ],
        "out": [],
        "env": [],
        "meta": {},
        "color": "#C0DEED",
        "icon": "node-red/bridge.svg"
    },
    {
        "id": "b122f18e514d14f9",
        "type": "mqtt out",
        "z": "be86292c6d08f0da",
        "name": "Internal MQTT Broker",
        "topic": "",
        "qos": "",
        "retain": "",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "dbd22c0713b05ef6",
        "x": 560,
        "y": 140,
        "wires": []
    },
    {
        "id": "dbd22c0713b05ef6",
        "type": "mqtt-broker",
        "z": "be86292c6d08f0da",
        "name": "Internal MQTT Broker",
        "broker": "internal-mqtt-broker",
        "port": "1883",
        "clientid": "node-red-mqtt-internal-out",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "sessionExpiry": ""
    }
]

This is the structure of the project.

.node-red
    package.json
    mqttout.js
    mqttout.json

Maybe have a look at this GitHub Issue, a patch seems to have resolved the problem bug: configuration of nodes goes missing upon deploying nodes packed within subflows · Issue #3798 · node-red/node-red · GitHub

I'm using the latest version of Node-Red. As #3798 said, utils.js has been updated.

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