Node-red running but editor gets stuck at loading nodes

The add-on is running (no errors in the log) but when I try and enter the editor the screen is stuck at “Loading Nodes 37/123”.

depends upon your installation. If native HA (not proxmox or such like) you hopefully have the Samba Addon installed.
If this is true stop nodered.
Open the samba share of HA and dive into addon_configs folder.
In there should be a folder named _ nodered
And in this folder is the flows.json
copy this to a save place.
restart node-red
your flows are gone since a new flows.json was created

now in node-red click the burger icon in the top right corner and select
import
you’re now allowed to import a flows.json
with some luck it’ll import flows but the one which is defective

if worse it might not allow to import the flows.json at all.
Then it depends how familar you are with json and it you remember your last modification. Normally one could cut out things if the result will be a valid json, which then could be imported.

EDIT:
Just had a closer look at the addon configuration. In it’s documentation it says you could add safe_mode … which perhaps does help, since it’ll load but not start the flows then. Might be the first thing to try.

Thanks for the reply. I will try safe_mode first. Hopefully I can update nodes from safe mode as I am guessing that is the issue.

Starting in safe mode didn’t resolve the issue. The editor still gets stuck trying to load the nodes so I can’t update any nodes that may need it. I will try removing the flows.json but I don’t think that removes the installed nodes which is what seems to be causing the problem.

A known problem that crops up from time to time, but again one that is very difficult to pin down to the exact cause, let alone fix it.

Since the Node-RED editor runs in JavaScript in a browser, it is not uncommon for the program to stall when starting, and a few clicks on ‘page fresh’ can sometimes sort that out.

The backstop ‘go-try’ solution is always to clear the front end cache, or try a different browser. Again, JavaScript in a browser can get stuck because of rubbish in the cache, or just because JS in that browser is having a bad day.

If the underlying issue is indeed with a node definition in the node module folder that is upsetting the editor (at load) then finding and removing this node module definition is going to be the solution. That, unfortunately, takes a bit of effort. Interestingly you have 123 nodes. I have 99 on my main HA NR as add-on, and 117 on my independent Raspberry Pi (to which I have recently added Dashboard 2 hence the extra node modules).

You can find the node modules, if you Samba into your HA add-on folder at addon_configs\a0d7b954_nodered\node_modules

Worth looking through any “node-red-contrib-” modules as these are all the extra contribution ones you will have added, and one of these is most likely to be the culprit. Otherwise, if you have recently added something to the palette, then look in date order for the most recent modules.

To get rid of any suspect module, this post on the Node-RED forum gives the npm instructions required. As I have not had this issue myself, I can’t say if it worked or not, but it may point you in the right direction.

Hope this helps

Thanks for the reply. I wish it was a browser issue but unfortunately after trying multiple browsers/computers I have been able to rule that out. I did just update a few nodes before the issue appeared so I will need to go through and start removing those nodes to find the “broken” one.

EDIT: So here are the nodes that were updated:
@matter
@noble
@sammachin
@node-red-contrib-themes
@insectos

Do I need to install npm to remove the node(s)? npm is showing “command not found”.

As far as I understand this (which is not that far TBH) the @ means this is a package or library of nodes, with several node-modules in a folder.

The node-red-contrib-themes should not be an issue, since this is a fairly standard addition for the themes used, however it might be worth checking that you have not installed a very recent update for this, since the HA add-on runs an older version of Node and Node-RED in the package.

You can always find out what versions are installed by digging down into each node-module and looking in the package.json. For my currently working HA NR add-on (which is up to date) node-red-contrib-themes is v 4.0.11. I don’t have any other the other nodes you quote, and clearly any could be the issue.

npm should be there already, as it is used by the palette manager of course.

To access npm as a command, without access to a command line, I am reminded that the exec node can be used to issue commands.

Kermit recently posted this, so just use the exec node with the command required to remove the node module.

If you have a standard HA Node-RED as add-on in supervised, then the command path should be as shown (/addon_configs etc).

Edit: yes as you say, without Node-RED working you can’t use the exec node (duh). See Mikefila post below…

I am not sure I understand what you are saying. I am using ssh to access the HA OS command line. I am not able to run npm from there (command not found). Am I suppose to be doing all of this from inside the node-red container? Also, I don’t understand how the exec node is applicable because I can’t access the node-red editor (the link you posted was for someone that could still access the node-red editor, just couldn’t install/update from the pallet).

You’ll need to get to the command line of the node red addon. The easiest way to get there is to install this version of portainer. From the gui browse to the nr container and choose console.

1 Like

I was able to access it using the “docker exec” command from the HA OS command line. I will now try the mpn command to remove the nodes.

Wow … normally a terminal and/or the samba addon should be enough against using techniques such as npm not to mention portainer.
Since these allow for more damage if being used the wrong way.

There’s 2 possible issue and likely only one of them leads to the problem.
Either a custom contrib plays havor or the flows.json is corrupted.

the flows.json could easily be validated pasting it’s content to any online json prettifier which suits, since most of them not only prettify but also validate and show the linenumber they stumbled across something giving a problem.

And the custom contribs could simply be wiped using either a terminal or samby by deleting them from the “node_modules” folder.

If one does fancy one could also remove them from the packages.json where all nodes are listed the actual projekct (flows.json) got as dependencies listed.

The addon terminal, advanced/standard, do not have the permissions to run commands in a container’s terminal using docker exec. At least that is what I recall when needing to execute commands in an addon container.

When I looked for a way there were 2 options, open port 22222 or use portainer. I am curious to see if @tribbles was able to use the standard/advanced terminal.

I didn’t try it with the terminal add-on because it doesn’t allow you to screen scrolling as far as I can tell. I directly ssh to the HA OS using putty.

I was unable to get “npm uninstall” to work, it didn’t seem to change anything. I was thinking about removing them from packages.json but was sure if that keeps them from loading when you enter the editor screen.

This what I was talking about the standard ssh port doesn’t have the permissions. You would need to ssh into port 22222. To do that you first need to enable access.

There is an addon that does it for you otherwise it’s a pia. Portainer just works right from the get go. You can also manually remove the files and edit the json but I am unsure of all the places that a node resides.

Are you referring to the “Advanced SSH & Web Terminal” add-on? I tried using that as well.

and in it’s configuration you entered 22222 for the portnumber?
and you disabled protection mode from it’s configuration screen?

No portainer you do not need to change any settings, leave the default. Log in use admin for the user and homeassistant for the password. The default password homeassistant can be changed on the configuration tab.

I have had that add-on for awhile now. I created my own username and password when I first installed it. And yes, I disabled protection mode.