ovebaa
ovebaa

Reputation: 13

My custom node in node-red is unusable after dropped into flow

I'm trying to make a custom node in Node-red, but as I drop the node into the flow, the node is "stuck" and unusable. The error from the console(F12) is:

Uncaught TypeError: Cannot read property 'hasOwnProperty' of undefined
at HTMLDivElement.drop (red.min.js:16)
at t.<computed>.<computed>._trigger (vendor.js:10)
at t.<computed>.<computed>._drop (vendor.js:15)
at t.<computed>.<computed>._drop (vendor.js:10)
at t.<computed>.<computed>.<anonymous> (vendor.js:15)
at Function.each (vendor.js:2)
at Object.drop (vendor.js:15)
at t.<computed>.<computed>._mouseStop (vendor.js:13)
at t.<computed>.<computed>._mouseStop (vendor.js:10)
at t.<computed>.<computed>._mouseUp (vendor.js:13)

I have simplified my node as much as I can but it still won't work. Here is my code:

findProtocol.js:

module.exports = function(RED) {
function FindProtocolNode(config) {
    RED.nodes.createNode(this,config);
    var msg = { payload:"hi" }
    this.send(msg);
}
RED.nodes.registerType("findProtocol",FindProtocolNode);
}

findProtocol.html:

<script type="text/javascript">
RED.nodes.registerType('findProtocol',{
    category: "Rpi RF Tools",
    outputs: 1,
    label: "Find Protocol"
});
</script>

package.json:

{
  "name": "node-red-contrib-rpi-rf-tools",
  "version": "1.0.0",
  "description": "",
  "node-red": {
    "nodes": {
      "findProtocol": "src/findProtocol/findProtocol.js"
    }
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "pigpio": "^3.2.4",
    "simple-statistics": "^7.3.2"
  }
}

Any ideas?

Upvotes: 1

Views: 391

Answers (1)

knolleary
knolleary

Reputation: 10117

I suspect the editor expects your node to have a defaults property in its HTML definition, even if it's an empty property.

<script type="text/javascript">
RED.nodes.registerType('findProtocol',{
    category: "Rpi RF Tools",
    outputs: 1,
    label: "Find Protocol",
    defaults:  {}
});
</script>

https://nodered.org/docs/creating-nodes/properties

As a minimum, your node should have a name property so the user is able to give it custom name/label in the editor.

Upvotes: 1

Related Questions