node-red/node-red-nodegen

Error: Invalid flow json - expected a single Function node

lgrkvst opened this issue · 2 comments

1st off, kudos, great idea and great execution! I've never had an issue before but this one seems odd:

What are the steps to reproduce?

  1. Create a simple subflow containing just a template node with 1 in and 1 out.
  2. Export to file.
  3. Run:

node-red-nodegen templateSubflow.json

My templateSubflow.json:
[{"id":"070cf268240bc7fe","type":"subflow","name":"Subflow 1","info":"","in":[{"x":50,"y":30,"wires":[{"id":"a107916f192722d2"}]}],"out":[{"x":340,"y":60,"wires":[{"id":"a107916f192722d2","port":0}]}]},{"id":"a107916f192722d2","type":"template","z":"070cf268240bc7fe","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"This is the payload: {{payload}} !","output":"str","x":190,"y":80,"wires":[[]]},{"id":"e904545de3f4cece","type":"subflow:070cf268240bc7fe","z":"7234bd72402e314c","name":"","x":660,"y":480,"wires":[[]]}]

What happens?

Error: Error: Invalid flow json - expected a single Function node
Error: Invalid flow json - expected a single Function node
    at Object.module.exports [as FunctionNodeGenerator] (/opt/homebrew/lib/node_modules/node-red-nodegen/lib/function/index.js:17:19)
    at Object.<anonymous> (/opt/homebrew/lib/node_modules/node-red-nodegen/bin/node-red-nodegen.js:142:39)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
    at node:internal/main/run_main_module:17:47

What do you expect to happen?

A successful creation of the subflow as a module.

Please tell us about your environment:

  • Node generator version: 0.2.4
  • Node-RED version: 2.1.3
  • Node.js version: v16.10.0
  • npm version: 7.24.0
  • Platform/OS: MacOS
  • Browser: N/A

Any ideas?

Thank you for using the Node generator. Your flow has no information about module property. To generate a custom node from subflow, you need to specify node module information on the following UI.

スクリーンショット 2022-06-13 23 22 00

Oh, I'm so sorry... At least you get to close an issue... =]