Node-red stopped working?

It's very tempting, however, on the Pi is quite a lot of other services that took a while set up. email server, ads-b, pi-hole, openvpn, transmission etc etc.
Just reinstalling NR seems the best option ...

You probably used sudo with npm and without -g at some point so that you have set root permissions on .node-red, to recover this run
sudo chown -R pi:pi ~/.node-red

Thanks Colin, That does ring a bell :thinking:

Running sudo chown -R pi:pi ~/.node-red reduced the error count a lot

pi@raspberrypi:~ sudo chown -R pi:pi ~/.node-red pi@raspberrypi:~ cd /home/pi/.node-red
pi@raspberrypi:~/.node-red $ sudo npm install node-red-contrib-isonline
npm WARN node-red-project@0.0.1 No repository field.
npm WARN node-red-project@0.0.1 No license field.

npm ERR! path /home/pi/.node-red/node_modules/node-telegram-bot-api/node_modules /.bin/mime
npm ERR! code EEXIST
npm ERR! Refusing to delete /home/pi/.node-red/node_modules/node-telegram-bot-ap i/node_modules/.bin/mime: is outside /home/pi/.node-red/node_modules/node-telegr am-bot-api/node_modules/mime and not a link
npm ERR! File exists: /home/pi/.node-red/node_modules/node-telegram-bot-api/node _modules/.bin/mime
npm ERR! Move it away, and try again.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-06-03T14_42_50_517Z-debug.log
pi@raspberrypi:~/.node-red $

You have done it again (using sudo with npm) only do that when installing a node globally (with -g), and only do it if there are specific instructions to do it. Run the chown again and try the install again.

damn it ! so I did I UP arrow'd rather than retype :anguished:

Now NR keeps loosing connection

Lost connection to server, reconnecting in 14s ...

What do you see in the terminal when you stop and restart node red

node-red-stop
node-red-start

When I connect to 192.168.1.40:1880 it promptly says lost connection to server

pi@raspberrypi:~ $ node-red-stop

Stop Node-RED

Use node-red-start to start Node-RED again

pi@raspberrypi:~ $ node-red-start

Start Node-RED

Once Node-RED has started, point a browser at http://192.168.1.40:1880
On Pi Node-RED works better with the Firefox or Chrome browser

Use node-red-stop to stop Node-RED
Use node-red-start to start Node-RED again
Use node-red-log to view the recent log output
Use sudo systemctl enable nodered.service to autostart Node-RED at every boot
Use sudo systemctl disable nodered.service to disable autostart on boot

To find more nodes and example flows - go to http://flows.nodered.org

Starting as a systemd service.
Started Node-RED graphical event wiring tool.
3 Jun 16:52:11 - [info]
Welcome to Node-RED

3 Jun 16:52:11 - [info] Node-RED version: v0.20.5
3 Jun 16:52:11 - [info] Node.js version: v10.16.0
3 Jun 16:52:11 - [info] Linux 4.9.35-v7+ arm LE
3 Jun 16:52:13 - [info] Loading palette nodes
3 Jun 16:52:19 - [info] Dashboard up and running
3 Jun 16:52:25 - [info] Worldmap version 2.0.12
3 Jun 16:52:30 - [info] Settings file : /home/pi/.node-red/settings.js
3 Jun 16:52:30 - [info] Context store : 'default' [module=memory]
3 Jun 16:52:30 - [info] User directory : /home/pi/.node-red
3 Jun 16:52:30 - [warn] Projects disabled : set editorTheme.projects.enabled=true to enable
3 Jun 16:52:30 - [info] Flows file : /home/pi/.node-red/flows_raspberrypi.json
3 Jun 16:52:30 - [warn]

Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.

3 Jun 16:52:30 - [info] Waiting for missing types to be registered:
3 Jun 16:52:30 - [info] - ui_base
3 Jun 16:52:30 - [info] - ui_tab
3 Jun 16:52:30 - [info] - ui_group
3 Jun 16:52:30 - [info] - darksky-credentials
3 Jun 16:52:30 - [info] Server now running at http://127.0.0.1:1880/

Does the same thing happen if you start it with the --safe option?

node-red-stop
node-red   --safe

Also which dashboard node are you running? The message
Dashboard up and running
is not what I would expect, unless it has changed recently. The supported one is node-red-dashboard. Note that you cannot have that and another dashboard node installed at the same time.

Yes it does the same thing - lost connection. Should be the standard dashboard I've never changed it (knowingly)

The dashboard is not available unless you install it.
I don't know why you would get the connection message, perhaps someone else can help

I'm really tempted to do node-red reinstall but unsure of the best way of doing it. .

At least I still have a backups of all the files..

But I'll wait until I do an
cd ~/.node-red
npm rebuild ??

or

bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)

HI. Here is a way to get back to something better.

  • Firstly, rename your ~/.node-red folder to something else.

  • Next, uninstall all global npm packages including Node-RED - you will need sudo for that. You can list everything with sudo npm -g ls --depth=0.

  • As this is a Pi, the next step is to use Dave's excellent script to reinstall Node-RED from scratch.

  • Finally, you can start up Node-RED, install the nodes you want using the palette manager and then copy/paste whatever you want from your old flow file.

The problems you've had are one of the reasons I don't ever install Node-RED the "standard" way.

I install Node-RED into its own folder, create a ./data sub-folder and add a "start" script to the package.json file in the Node-RED root folder that directs Node-RED to use the data folder as its userDir.

That way, you should never need to use sudo to install any nodes or indeed other packages you might want. Even Node-RED doesn't need to be installed with sudo this way.

Thank you, Some questions.

sudo npm -g ls --depth=0

returns
pi@raspberrypi:~ $ sudo npm -g ls --depth=0

/usr/lib
├── node-red@0.20.5
└── npm@6.9.0

Where do I find Dave's script ?

https://nodered.org/docs/hardware/raspberrypi

I note that you have an old version of Node.js as well. The script will update that for you. It installs everything the "standard" way. You can use the script in the future to update Node.js, npm and Node-RED.

@TotallyInformation Well spotted , previously ran 'bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)' I assumed that would update everything

It is 10.16.0 that is up to date isn't it?

Ah, sorry, I missed that 2nd output. You are right, you did manage to update it.

So it looks like you are ready to rebuild your flows. Renaming the ~/.node-red folder at this point and then running Node-RED will give you a completely clean environment to start from.

Before you do though, worth checking that you haven't managed to change permissions on the home folder. ls ~/* -la should do the job I think. You will be able to see all of the ownership. If there is any root ownership, I would fix that first.

ls ~/* -la gives a very long list - I forgot how to send it to a file. (Glad the update worked)

I have to go out for a bit (shopping :roll_eyes:) but when back I'll do the following

Rename ~/.node-red to ~/.node-redOLD
post the permissions output of ls ~/* -la to here then run bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)

then reload my flows and update the missing nodes and creds

ls ~/* -la | grep root
will show you if you have any files or folders owned by root.