Missing nodes in Nodes list

I have written a simple node that should interact with minecraft server using RCON protocol.
For some reason, I can see the Nodes in the Palette view, and both of them are shaded, but enabled.
I do not see them in the Nodes list in the Flow editor.

What could be the problem?

Did you get a message to restart Node-RED - some installations require that. Then you would need to also reload the Editor page.

Yes,
I have restarted the Node-red, didn't help.

And reloaded the page?

Check the Node-RED log for issues. Then also check the console on the dev tools for the Editor page.

There are no logged errors, or anything in the browser console.

This is my Nodes code:

package.json

{
    "name": "node-red-Minecraft-Server-Connector",
    "version": "0.0.5",
    "description": "Node-RED nodes to interact Minecraft Server using RCON protocol",
	"author": "Dovev Golan",
    "dependencies": {
        "rcon-client": "latest"
    },
    "node-red": {
        "nodes": {
            "rcon-server": "./mc-server",
            "rcon-command": "./mc-command"
        }
    }
}

mc-command.html

<script type="text/javascript">
    RED.nodes.registerType('mc-command',{
        category: 'Minecraft',  // The category in the sidebar under which this node will appear
        color: '#FFA500',  // Orange color
        defaults: {
            server: {type: "mc-server", required: true},
        },
        inputs: 1,
        outputs: 1,
        icon: "cog",  // You can specify a custom icon if you want
        label: function() {
            return this.name || "RCON Command";
        }
    });
</script>


<script type="text/html" data-template-name="mc-command">
    <div class="form-row">
        <label for="node-input-server"><i class="fa fa-server"></i> Server</label>
        <input type="text" id="node-input-server" placeholder="Server">
    </div>
</script>

<script type="text/html" data-help-name="mc-command">
    <p>This node sends RCON commands to a Minecraft server.</p>
</script>

mc-command.js

const Rcon = require('rcon-client');

module.exports = function(RED) {
    function RconCommandNode(config) {
        RED.nodes.createNode(this, config);
        
        this.server = RED.nodes.getNode(config.server);
        var node = this;

        node.on('input', function(msg) {
            const rcon = new Rcon({
                host: this.server.host,
                port: this.server.port,
                password: this.server.password,
            });

            rcon.connect()
                .then(() => {
                    return rcon.send(msg.payload);
                })
                .then(response => {
                    msg.payload = response;
                    rcon.end();
                    node.send(msg);
                })
                .catch(error => {
                    node.error(error);
                });
        });
    }

    RED.nodes.registerType("mc-command", RconCommandNode);
};

mc-server.html

<script type="text/javascript">
    RED.nodes.registerType('mc-server', {
        category: 'Minecraft',
		color: '#a6bbcf',
		icon: "cog",
        defaults: {
            host: {value: "", required: true},
            port: {value: "", required: true},
            password: {value: "", required: true}
        },
        label: function() {
            return this.name || "RCON Server";
        }
    });
</script>
<!-- More code for HTML form here -->

mc-server.js

module.exports = function(RED) {
    function RconServerConfigNode(config) {
        RED.nodes.createNode(this, config);
        this.host = config.host;
        this.port = config.port;
        this.password = config.password;
    }
    
    RED.nodes.registerType("mc-server", RconServerConfigNode);
}

What am I doing wrong?

The names are mismatched. They all need to be rcon-command

I have updated Package.json as follow:

{
    "name": "node-red-Minecraft-Server-Connector",
    "version": "0.0.8",
    "description": "Node-RED nodes to interact Minecraft Server using RCON protocol",
	"author": "Dovev Golan",
    "dependencies": {
        "rcon-client": "latest"
    },
    "node-red": {
        "nodes": {
            "mc-server": "./mc-server",
            "mc-command": "./mc-command"
        }
    }
}

The result is still the same...

For mc-server.html
The category needs to be config if its being used as a config node

Configuration nodes : Node-RED (nodered.org)

As for your package.json
whilst i think its not causing issues, i would do.


 "nodes": {
            "mc-server": "mc-server.js",
            "mc-command": "mc-command.js"
        }
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.