# Is the Packaging Subflow Modules Documentation Obsolete or needs update?

**URL:** <https://discourse.nodered.org/t/is-the-packaging-subflow-modules-documentation-obsolete-or-needs-update/61751>\
**Category:** General\
**Created:** [25 April 2022 12:14 UTC](https://discourse.nodered.org/t/is-the-packaging-subflow-modules-documentation-obsolete-or-needs-update/61751 "2022-04-25T12:14:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shan](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@Shan](https://discourse.nodered.org/u/Shan)\
**Post date:** [25 April 2022 12:14 UTC](https://discourse.nodered.org/t/is-the-packaging-subflow-modules-documentation-obsolete-or-needs-update/61751/1 "2022-04-25T12:14:46Z")

</div>

I am not sure but packing the the respective nodes into `flow` array as mentioned in the Documentation for node-red v2.2 doesn't work when packaging the subflow as a module.

### JSON Generated during Export

The documentation [Packaging a Subflow as a module : Node-RED](https://nodered.org/docs/creating-nodes/subflow-modules) suggests that the Exported JSON takes the form of

```json
[
   { "id": "Node 1", ... },
   { "id": "Node 2", ... },
   ...
   { "id": "Node n", ... },
   { "id": "Subflow Definition Node", ... },
   { "id": "Subflow Instance Node", ... }
]

```

For version 2.2.2 this is quite the contrary since the structure is generally

```json
[
    {
        "id": "f40ab2fe576b55f7",
        "type": "subflow",
        "name": "..",
        "info": "..",
        "category": "",
        "in": [
            {
                "x": 480,
                "y": 140,
                "wires": [
                    {
                        "id": "f06facfb30103d6c"
                    }
                ]
            }
        ],
        "out": [
            {
                "x": 940,
                "y": 140,
                "wires": [
                    {
                        "id": "f06facfb30103d6c",
                        "port": 0
                    }
                ]
            }
        ],
        "env": [],
        "meta": {},
        "color": "#C0DEED",
        "icon": "node-red/bridge.svg"
    },
    {
        "id": "f06facfb30103d6c",
        "type": "mqtt in",
        "z": "f40ab2fe576b55f7",
        "name": "Internal MQTT Broker",
        "topic": "",
        "qos": "2",
        "datatype": "auto",
        "broker": "b5bc2cca74215822",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 1,
        "x": 700,
        "y": 140,
        "wires": [
            []
        ]
    },
    {
        "id": "b5bc2cca74215822",
        "type": "mqtt-broker",
        "z": "f40ab2fe576b55f7",
        "name": "Internal MQTT Broker",
        "broker": "internal-mqtt-broker",
        "port": "1883",
        "clientid": "node-red-mqtt-internal-in",
        "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": ""
    }
]

```

Even upon packing the dedicated nodes under `flow` array (as mentioned in the documentation) provides errorenous node (mostly under the `function` palette.

## Tests

- running two instances of `nodered/node-red:2.2.2` with different published ports e.g. `1880` and `1990`
- create a simple subflow with MQTT In and export the subflow JSON to the clipboard.
- Paste the same JSON into the other instance of Node-Red and the node is available readily without having to change the export values

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [25 April 2022 12:50 UTC](https://discourse.nodered.org/t/is-the-packaging-subflow-modules-documentation-obsolete-or-needs-update/61751/2 "2022-04-25T12:50:22Z")

</div>

Without knowing exactly what you have done to package your subflow it's hard to say what is happening.

The process of converting the JSON exported by the editor into the right format to package into a module is a little cumbersome. The intention was always to create some tooling to help with that... but it hasn't happened.

It _is_ true to say when exporting a subflow instance from the editor, the JSON does have the definition node at the start and not the end - so yes, the docs need updating to reflect that.

```auto
[
   { "id": "Subflow Definition Node", ... },
   { "id": "Node 1", ... },
   { "id": "Node 2", ... },
   ...
   { "id": "Node n", ... },
   { "id": "Subflow Instance Node", ... }
]

```

But that point aside, following the instructions in the docs should still work. If it is failing for you, then please provide an example subflow module you have created so we can look at what you've done.

---

<div class="post-metadata">

**Author:** ![Shan](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@Shan](https://discourse.nodered.org/u/Shan)\
**Post date:** [25 April 2022 12:52 UTC](https://discourse.nodered.org/t/is-the-packaging-subflow-modules-documentation-obsolete-or-needs-update/61751/3 "2022-04-25T12:52:39Z")

</div>

@knolleary Thanks for reaching out I am currently documenting the potential workflow In the following

> [@How to package node-red subflows into a dedicated Node-Red Docker Container?](https://discourse.nodered.org/t/how-to-package-node-red-subflows-into-a-dedicated-node-red-docker-container/61745):
>
> I have created a subflow for the standard mqtt in and mqtt out nodes which sets the broker address accordingly (docker container names of the MQTT broker) and is made available for the use in the node pallete. The node pallete looks as follows: [image] The subflow is very simple, it is just a wrapper around the mqtt in and mqtt out nodes but the mqtt properties are configured to the broker address instead of localhost Internal MQTT In Node [image] Internal MQTT Out Node [image] Document…

I am just about to put an update to what the status is and what the workaround currently is.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [25 April 2022 12:59 UTC](https://discourse.nodered.org/t/is-the-packaging-subflow-modules-documentation-obsolete-or-needs-update/61751/4 "2022-04-25T12:59:55Z")

</div>

As you already have a thread open on this topic, I'll close this one and we can focus discussion in one place.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [25 April 2022 12:59 UTC](https://discourse.nodered.org/t/is-the-packaging-subflow-modules-documentation-obsolete-or-needs-update/61751/5 "2022-04-25T12:59:59Z")

</div>


