Making a custom node and getting ERROR : Waiting for missing types to be registered

#1

On my machine,
nodejs version : 8.15.1
npm version : 6.4.1

I have made a simple node that generates any random number.
I'm sharing the sequence of steps that I did so that it becomes simple and easy for you to understand...(I have correctly followed the documentation link, https://nodered.org/docs/creating-nodes/first-node. Just for the sake I'm listing steps here..:sweat_smile:)

  1. in an arbitrary folder /nodered-random-num performed npm init.
  2. inserted this code in package.json file i.e.
    "node-red" : {
    "nodes" : {
    "random-num" : "nodes/random-num.js"
    }
    }
  3. created random-num.html and random-num.js files inside /nodes folder
  4. Now, I setup the npm link of folder /nodered-random-num inside /.node-red folder in my user-directory.
  5. run node-red command on cmd

log created on cmd is below.......

when I do input from inject node, following error gets displayed on dev-console of browser....

I have literally tried everything..like downgraded my npm, checked file .config.json also where my random-num node is even present there but it is unable to fetch its type, I don't know :neutral_face:

Please help me guys! As I'm new to node-red, I was just trying to learn by creating my own example Any suggestion is helpful..

0 Likes

#2

You need to add some debugging output to your node so that you can see where it is failing.

You need to get beyond the missing types issue. What this is saying is that your node cannot be require'd into Node-RED. That implies that there is an error in the code or something is missing from the code that Node-RED is reliant on.

0 Likes

#3

Thanks for your reply Sir...
One output debug node is already there in the flow. The problem I'm facing is that when the flow is being deployed it is throwing error that Flow stooped due to missing node type : random-num

If flow does not get deployed, how can I see where it is failing

my random-num.js file is :

module.exports = function(RED) {
	"use strict";
	function RandomNode(num) {
		RED.nodes.createNode(this,num);
		this.property = num.property || "payload";
		var node = this;
		this.on("input", function(msg) {
            var val;
            val = Math.round(Math.random() * 100);
            console.log("random number : " + val + "\n");
            RED.util.setMessageProperty(msg,node.property,val);
	        console.log("***** i m here *****");
	    node.send(msg);
		});
	}
		RED.nodes.registerType("random",RandomNode);
}
0 Likes

#4

Please wrap code in back-ticks so that it is properly formatted.

I can't immediately see an error but hard to read without formatting and I need to get back to work. You will need to put some more debug statements in different places.

If it helps at all, I have an annotated example node called node-red-contrib-jktest. I've tried to put best practice into it.

0 Likes

#5

You code is registering a node of type random:

RED.nodes.registerType("random",RandomNode);

Not random-num which is what your flow is waiting for.

0 Likes

#6

The very first step should be to see if one exists already by checking on flows.nodered.org - and then to see if it saves you having to write any code in the first place :-)...

Next step is then to see if fixing/enhancing one of the existing ones would make it do what you want - in which case use that as a starting point... or better - offer to make changes to the original so it is improved for all.

And then... break out the editor and build your own. Have fun and good luck !

0 Likes

#7

Got it @knolleary sir...really thanks a lot.
I hadn't understood the syntax at first place even.

@dceejay and @TotallyInformation thank you for the advice Sir
:smiley:

0 Likes