'name' already registered by module node-red

I'm creating a new node for the first time in Node-RED. I ran through the tutorial on creating my first node to change the input to lowercase.

However, after installing the node, I always get 'name' already registered by module node-red. I changed the name of my node several times, but this error still appears in both the pallet and the console.

image

Startup Logs
4 Jun 17:19:11 - [info] 
2024-06-04T17:19:11.807805410Z 
2024-06-04T17:19:11.807809120Z Welcome to Node-RED
2024-06-04T17:19:11.807811230Z ===================
2024-06-04T17:19:11.807813100Z 
2024-06-04T17:19:11.808093868Z 4 Jun 17:19:11 - [info] Node-RED version: v3.1.4
2024-06-04T17:19:11.808317982Z 4 Jun 17:19:11 - [info] Node.js  version: v16.20.2
2024-06-04T17:19:11.808397147Z 4 Jun 17:19:11 - [info] Linux 5.15.146.1-microsoft-standard-WSL2 x64 LE
2024-06-04T17:19:12.059360925Z 4 Jun 17:19:12 - [info] Loading palette nodes
2024-06-04T17:19:12.653989717Z 4 Jun 17:19:12 - [info] Dashboard version 3.6.2 started at /ui
2024-06-04T17:19:12.796686287Z 4 Jun 17:19:12 - [warn] ------------------------------------------------------
2024-06-04T17:19:12.797415818Z 4 Jun 17:19:12 - [warn] [node-red-contrib-ntc/ntc-test] 'ntc-test' already registered by module node-red
2024-06-04T17:19:12.797557282Z 4 Jun 17:19:12 - [warn] ------------------------------------------------------
2024-06-04T17:19:12.797874718Z 4 Jun 17:19:12 - [info] Settings file  : /data/settings.js
2024-06-04T17:19:12.798382756Z 4 Jun 17:19:12 - [info] Context store  : 'default' [module=memory]
2024-06-04T17:19:12.798927254Z 4 Jun 17:19:12 - [info] User directory : /data
2024-06-04T17:19:12.799051436Z 4 Jun 17:19:12 - [warn] Projects disabled : editorTheme.projects.enabled=false
2024-06-04T17:19:12.799298583Z 4 Jun 17:19:12 - [info] Flows file     : /data/flows.json
2024-06-04T17:19:12.804582207Z 4 Jun 17:19:12 - [info] Server now running at https://127.0.0.1:1880/
2024-06-04T17:19:12.806099503Z [2024-06-04 17:19:12.805] [INFO] NodeRed FlowManager - Flow filtering state: []
2024-06-04T17:19:12.840321409Z 4 Jun 17:19:12 - [warn] Using unencrypted credentials
2024-06-04T17:19:12.876872884Z 4 Jun 17:19:12 - [info] Starting flows
2024-06-04T17:19:12.887547632Z 4 Jun 17:19:12 - [info] [mongodb4-client:58bf183a277d3721] client initialized with app name 'nodered-dzgvo3fk'
2024-06-04T17:19:13.014891560Z 4 Jun 17:19:13 - [info] Started flows
2024-06-04T17:19:13.016197118Z 4 Jun 17:19:13 - [info] [tcp in:From External] listening on port 8181
2024-06-04T17:19:13.076215388Z 4 Jun 17:19:13 - [info] [mqtt-broker:a5ac06f6.ba88c8] Connected to broker: nodered@mqtts://mqtt:8883

What's odd is that I can still use the node within the Node-RED dashboard and it works, but this error still shows:

It's worth mentioning that I'm running this within a Docker container.
Here is the basic lower-case node (but renamed):

ntc-test.js
module.exports = function(RED) {
    function NTCTestNode(config) {
        RED.nodes.createNode(this, config);
        var node = this;
        node.on('input', function(msg) {
            msg.payload = msg.payload.toLowerCase();
            node.send(msg);
        });
    }
    RED.nodes.registerType("ntc-test", NTCTestNode);
}
ntc-test.html
<script type="text/javascript">
    RED.nodes.registerType('ntc-test', {
        category: 'function',
        color: '#a6bbcf',
        defaults: {
            name: {value: ""}
        },
        inputs: 1,
        outputs: 1,
        icon: "file.svg",
        label: function () {
            return this.name || "ntc-test";
        }
    });
</script>

<script type="text/html" data-template-name="ntc-test">
    <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>
</script>

<script type="text/html" data-help-name="ntc-test">
    <p>A simple node that converts the message payloads into all lower-case characters</p>
</script>
package.json
{
  "name": "node-red-contrib-ntc",
  "version": "1.0.0",
  "description": "Testing NTC",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "node-red": {
    "nodes": {
      "ntc-test": "ntc-test.js"
    }
  },
  "devDependencies": {
    "@node-red/editor-api": "^3.1.9",
    "@node-red/nodes": "^3.1.9",
    "@node-red/runtime": "^3.1.9",
    "@node-red/util": "^3.1.9",
    "node-red": "^3.1.9"
  }
}

I appreciate any help!

What did you put in the node-red package.json?

@marknomad - Why didn't you use a scoped name, as described in the Node-RED 'Creating nodes' documentation?
https://nodered.org/docs/creating-nodes/packaging

This is my entry in the /data/package.json:
"node-red-contrib-ntc": "file:nodes"

I haven't seen any other nodes use it so I wasn't aware that was a requirement and didn't see that article. I'll see about updating that; is it likely that it has anything to do with this issue?

No, but I thought that I'd point it out, as it's easier to change name before others start using the node.

2 Likes

It was changed...

So most nodes (that have been around for sometime), are not subject to this requirement.
There is logic in place to lookout for this (previous V new nodes)

But onto your problem.

I see you are using a docker image for Node RED... so what are you using (HA) ?
and how are you installing your development Node?

have you changed the name of your node, and installing it ontop of your original name?
if so, Node RED is letting you know another Node that is using this name (type name) is already installed by another Node.

i.e have you changed to node-red-contrib-ntc from another name - without first removing the old named instance (using the same node type name)

The type name is globally unique (across the Node RED estate), technically so is the package name (but that is more an npm thing)

I haven't changed the name without doing a clean build of the image. This image is for a environment like HA using Docker.

Here's my Dockerfile and main package.json if it helps at all:

Dockerfile

FROM nodered/node-red:3.1.9
COPY --chown=node-red:node-red settings.js /data/settings.js
COPY --chown=node-red:node-red package.json /data/package.json
COPY --chown=node-red:node-red nodes/* /data/nodes/
RUN npm --prefix /data install /data
COPY --chown=node-red:node-red config/* /data/
COPY --chown=node-red:node-red subflows/* /data/subflows/
COPY --chown=node-red:node-red flows/* /data/flows/

package.json

{
"name": "ntc-node-red",
"description": "",
"version": "1.1.0",
"private": true,
"dependencies": {
"uuid": "9.0.0",
"mongodb": "5.8.1",
"node-red-dashboard": "3.6.2",
"node-red-contrib-flow-manager": "0.7.4",
"node-red-contrib-heap-dump": "0.0.2",
"node-red-contrib-mongodb4": "2.5.2",
"node-red-contrib-topic-link": "0.1.0",
"node-red-contrib-splitter": "0.0.16",
"node-red-contrib-buffer-parser": "3.2.2",
"node-red-contrib-delay-topic-message": "1.3.1",
"node-red-node-serialport": "2.0.2",
"node-red-node-snmp": "2.0.0",
"node-red-contrib-modbus": "5.27.2",
"node-red-contrib-socketcan": "1.2.9",
"node-red-contrib-ntc": "file:nodes"
}
}

And the project structure:
image

Ok,

Many here do not use HA, so my guess is there is persistence somewhere,
Like the data folder that lives between images (if I'm not mistaken)

Nodes are not installed into the apps directory, but a user directory, this is your breadcrumb.

Standard Node RED, the user directory is ~/<username>/.node-red
but for HA and others alike - they create their own

Thanks for your help!

TLDR: moving out of the /data directory (e.g. /nodes not /data/nodes) seems to have fixed the issue.

After debugging this quite a bit more, I was able to figure out that if i removed the "ntc-test": "ntc-test.js" entry from my package.json the node still remained.

Furthermore, I actually looked at the node-red section of my palette and found ntc-test listed as if Node-RED registered it (as it said in the logs).

Then by happenstance, I was looking at the name scoping and saw this section which uses a subdirectory for the node:

I added a subdirectory and added back the entry to my package.json; "ntc-test": "test/ntc-test.js". Following a reinstall and restarting the container, Node-RED no longer had the ntc-test node installed, but once I fully rebuilt the container it still showed up.

Finally, I moved the nodes directory completely outside of the /data directory from /data/nodes to /nodes. Now when rebuilding the container Node-RED no longer has the node and everything works as expected.

Node-RED must be picking up the .js files regardless of depth in the /data directory or something along those lines.

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