Is there a simple way to generate a custom node from .js file.
I tried node-red-nodegen in vain .getting following error.
Error: TypeError: Cannot read property 'match' of undefined
My plan is to have a library of nodes / subflows which can be shared among many users.
Not that simply. nodegen works either from an existing function node - or a swagger definition file - or a web of things definition file. There are plans to try to make subflows exportable as nodes also - but that is still a plan. Until then, you will need to do the wrapping / creation yourself. https://nodered.org/docs/creating-nodes/first-node
Two things
(1) You need to create the .js file in an editor outside node-red. The file must have a name comment line and an outputs comment line as follows (spaces are required)
(2) the explaination in the documentation is incorrect since the export (as far as I can see) only saves json files. I've added a note in one of the closed incidents in node-red-nodegen's GitHub page
hmm - If I save a function as it says then run the command as it says - it creates a node OK... admittedly it calls it node-red-contrib-unnamed-function but is created in the directory you run the command in... so should be easy to find and edit from there.
But yes adding the name parameter up front would make it easier, and less editing later.
I am using windows 8.1. Without passing name it didn't work for me. Also i tried in linux, did not work without name. Again in window 8.1 it appeared in palette manager but not in nodes panel where all nodes are listed. This is super node for my need, but these issues stops me from using, still struggling to make it work.
I think you did some contract work for us a few years ago.
If you don't publish the nodes to NPM and install through the package manager pallet in node red, your custom made nodes do not get added to the package.js in the node red folder. I think the purpose of this is to stop malware sneaking into your node red instance.
So your home made nodes wont be picked up.
To get around this you have to add your custom node to the package.js file in the node red folder.
Add your node name and make sure the versioning is correct.
Some times its better to first add the node details to the package.js then add your node-red-contrib-MyHomeMadeNode to the relevant node red folder.
Restart node red it should be good to go.
Tip, when using nodered-gen tool, give the function block a name, the tool will use this name as the package name.
Did you follow my steps ? You have to manually add the dependency to the node to the Node-Red Package.js file ?
When i say manually i mean you have to physically type/enter the node details to that file.
I just used node-red-nodegen to generate a node from a function node and after following all the steps and stop/starting node-red, the node shows up in node-red.
Make sure you are using a name that is not already a existing node.