Custom node not appear in the category

Hi, I have created a custom node and installed it in nodered. It appears in manage-pallette but not in the category.

my package.json

{
    "name" : "node-red-contrib-simulation-quantity-add",
    
    "node-red" : {
        "nodes": {
            "quantity-add": "quantity-add.js"
        }
    }
}

quantity-add.html:

<script type="text/javascript">
    RED.nodes.registerType('quantity-add',{
        category: 'function',
        color: '#a6bbcf',
        defaults: {
            name: {value:""},
            type: {value:""}
        },
        inputs:1,
        outputs:1,
        icon: "file.png",
        label: function() {
            return this.name||"quantity-add";
        }
    });


</script>

<script type="text/html" data-template-name="quantity-add">
    <div class="form-row">
        <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
        <input type="text" id="node-input-name" placeholder="Name">
    </div>
    <div class="form-row">
        <label for="node-input-type"><i class="fa fa-tag"></i> Quantity type</label>
        <input type="text" id="node-input-type" placeholder="Type">
    </div>
</script>

<script type="text/html" data-help-name="quantity-add">
    <p>A digitalTwin simulation's custom node for adding quantity</p>
</script>

quantity-add.js :

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


        var type = config.Type;

        node.on('input', function (msg) {
     
            node.send(type);
        });
    }
    RED.nodes.registerType("quantity-add", QuantityAddNode);
}

where does it appear then - please show or explain


As you can see its installed successfully but does not appear in the function category

How is the node installed - from NPM? or from symlink or other? Was it a --global install?

If symlinked in node_modules...

  • ensure modifications are changed
  • restart node-red
  • try refreshing (hard cache clearing refresh)
  • try searching the left hand palette for quantity

npm install C:\Users\golamk.node-red\custom\quantity-add

I tried all of the suggestions but they didn't work for me

Maybe you can try:
npm pack within your projects root folder, then upload the result using the upload module function?

Might be worth taking it out of Node RED first?
The only factor I can see is the method of install.

  • Are there any errors in the node-red console when you start node-red?
  • Try adding a palletLabel property to the node
  • Have you tried the search box in the palette?
  • What if you set a different category?
  • Are there any errors in the browser console?
  • Try adding console.log("hi from my node, I am just above RED.nodes.registerType('quantity-add'...") and console.log("hi from my node, I am inside the label() function")
  • where is quantity-add.js in relation to package.json?

console.log doesn't work and I'm getting an error "BAIL on node-red-contrib-quantity-add/quantity-add


"

Lets approach this with some basics.

  1. Your modules folder should be structured as follows.

Note: Its a personal choice, that I put the guts of the package In a nodes folder, but I (don't think) its a requirement - as long as package.json correctly references the location of the main entry point.

The icons folder, should be in the same location as your html & js file

  • quantity-add (dir)
    • package.json
    • nodes (dir)
      • quantity-add.js
      • quantity-add.html
      • icons
        • file.png (based on your html file)
  1. Your package.json file
{
    "name" : "node-red-contrib-simulation-quantity-add",
    "version": "0.0.1",
    "engines": {
		"node": ">=12.22.2"
	},
    "node-red" : {
        "nodes": {
            "quantity-add": "nodes/quantity-add.js"
        }
    }
}

if all this checks out, within your packages directory (in my example above that will be quantity-add)
run npm pack and upload it via the User Interface.

(once again - it may be better to remove any trace of it thus far from node red)
The only thing that is sticking out at me, is your method of install.

No, that is how I always install my dev node packages. I have multiple ones installed right now.

Does it work for sub folders?

npm install C:\Users\golamk\.node-red\custom\quantity-add
                                         ^
  "dependencies": {
    "@node-red-contrib-themes/theme-collection": "^2.2.0",
    "@totallyinformation/node-red-experimental-nodes": "file:../../node-red-experimental-nodes",
    "chokidar": "^3.5.3",
    "collection-red": "~0.0.5",
    "csv-parser": "^3.0.0",
    "ejs": "^3.1.6",
    "fast-glob": "^3.2.11",
    "fs-extra": "^10.0.1",
    "googleapis": "^39.2.0",
    "mqtt": "^4.2.8",
    "node-drayton-wiser": "file:../../node-drayton-wiser",
    "node-red-contrib-cron-plus": "~1.5.4",
    "node-red-contrib-events": "file:../../node-red-contrib-events",
    "node-red-contrib-jktesting": "file:../../node-red-contrib-jktesting",
    "node-red-contrib-simple-gate": "~0.5.2",
    "node-red-contrib-telegrambot": "~11.3.0",
    "node-red-contrib-uibuilder": "file:../../node-red-contrib-uibuilder",
    "node-red-dashboard": "~3.1.7",
    "node-red-node-discord": "~2.2.0",
    "node-red-node-random": "~0.4.0",
    "node-red-node-sqlite": "~1.0.3",
    "red-contrib-drayton-wiser": "file:../../node-red-contrib-drayton-wiser",
    "wmi-client": "^0.5.0"
  },

The install is done as npm install c:\src\node-red-contrib-drayton-wiser, npm changes it to a relative file path.

Cool.

I usually pack during development - so wasn't sure if sub level folders were an issue in windows.
I don't use windows :sweat_smile:

No, it is fine and means that you only need to restart node-red if there is a change to the source. I do that automatically via PM2 with defined watch folders.

I develop on Windows and run on Linux.

:slight_smile:

Also, slight update to your package.json example. It should include an "engines" property to show the minimum version of node.js supported.

Also, slight update to your package.json example. It should include an "engines" property to show the minimum version of node.js supported.

Yup - I also, Copy and paste job from this discussion :sweat_smile:

edited

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