Unable to install node-red - on raspian buster 2020-02-13

Hi, on my PI 3B I've installed the last raspian buster (release data 2020-02-13 image with desktop based on Debian Buster). I'm getting mad, trying several time even reinstalling the OS, but I cannot install node-red in any way. I've tryed with the script, manually installing npm and nodejs ... but nothing.
Now the official script freeze for several hours on "install Node-RED core"
image


If I try to install it manually or by "recommended software" I get this error
image

What happens if you run
sudo npm install -g --unsafe-perm node-red
Please copy/paste the result rather than screenshot, if possible.

Edit actually, before trying that, run
sudo apt update && sudo apt full-upgrade
And copy/paste here if that fails. If possible please supply a translation of the error message to English.

Further edit Having looked again at the previous error message I see you have somehow got an old version of npm installed, possibly because you installed it manually, so before doing either of the above run
sudo apt remove nodejs npm nodered

1 Like

ok, as soon as possible I'll be back with the result of the action you suggest.
Having looked again at the previous error message I see you have somehow got an old version of npm installed, possibly because you installed it manually

Blockquote Further edit Having looked again at the previous error message I see you have somehow got an old version of npm installed, possibly because you installed it manually

The first and only thing I did on the new OS was installed node-red via script. But since the beginning it went block at the same point. And even instaling it manually or by "reccomended software" it gave me the same error related to npm. So I uninstalled npm and jason and reinstall them manually in order to be sure to have the last version. But the errore still remain and node-red installation get block. For this reason you see npm already installed.

What model Pi are yo using?
How large is the SD card? - in the command line enter df -h and show the results.

Here we are:
@ zenofmud
Its a GB SD card. PI model B
image

@ Colin
with "sudo apt remove nodejs npm nodered" it says that npm and nodered are not installed, than won't be removed. It only removed nodejs (10.19.0-1nodesource1)
with "sudo npm install -g --unsafe-perm node-red" it says
sudo: npm: command not found

pi@rw:~ $ sudo apt remove nodejs npm nodered
Lettura elenco dei pacchetti... Fatto
Generazione albero delle dipendenze       
Lettura informazioni sullo stato... Fatto
Il pacchetto "npm" non è installato e quindi non è stato rimosso
Il pacchetto "nodered" non è installato e quindi non è stato rimosso
I seguenti pacchetti saranno RIMOSSI:
  nodejs
0 aggiornati, 0 installati, 1 da rimuovere e 0 non aggiornati.
Dopo quest'operazione, verranno liberati 77,3 MB di spazio su disco.
Continuare? [S/n] s
(Lettura del database... 101239 file e directory attualmente installati.)
Rimozione di nodejs (10.19.0-1nodesource1)...
Elaborazione dei trigger per man-db (2.8.5-2)...
pi@rw:~ $ sudo npm install -g --unsafe-perm node-red
sudo: npm: comando non trovato

I trayed again, and the same error appear
image

Have you done that?
Installing node-red with apt is not the recommended way. Once the update and full-upgrade works ok then try the script again.

Unfortunately, you've confused the npm package installations with the apt package installations.

nodejs is installed via apt. npm and node-red are installed via npm (yes it is a little weird to have npm install itself and I'm glossing over the detail).

As you already seem to have removed nodejs, you can no longer remove npm or anything else that got installed by npm into the global location.

If you try the following commands, you should be able to see any remaining executable files which you can manually delete:

pi@pi3:~ $ whereis npm
npm: /usr/bin/npm
pi@pi3:~ $ whereis nodejs
nodejs: /usr/bin/nodejs /usr/share/man/man1/nodejs.1.gz

This was from my own Pi which isn't running buster but it should be similar for you.

In addtion, you will need to manually remove any globally installed modules and you should be able to find the /usr/lib/node_modules/ folder. You can safely delete the whole node_modules folder.

2 Likes

Not necessarily true. On a standard Raspbian install npm is available in the repository for installation with apt, and the OP said he had tried to do that, which is why I got him to remove them again with apt, in case they were installed. The node-red install script installs nodejs from the nodesource repository and that automatically installs npm too.

After I did what Colin suggested, I tryed again with the official script and finally I did it
image
Honestly I donìt know what's happened!

1 Like

I don't know why the install script did not run the first time, but having investigated, it is not possible to use apt to install node red from the Raspbian Buster repository. I get the same issue you did that the version of npm in the repo is 5.8.0 but node red needs > 5.8.0. So there is a packaging error in the repository at the moment and it is not possible to install node-red via that route. I suspect that the error is that node-red actually requires >=5.8.0 rather than >5.8.0 but that is purely a guess.

At the end we did it. Thanks a lot

@colin not sure why can happen - the deb is built with
Depends: nodejs (>= 10), npm (>= 5.8), python (>= 2.7)

It seems I mis-spake slightly the first time. When I try to install I get

The following packages have unmet dependencies:
 nodered : Depends: npm (>= 5.8)

as did @Lupin_III but

apt policy npm
npm:
  Installed: (none)
  Candidate: 5.8.0+ds6-4
  Version table:
     5.8.0+ds6-4 500
        500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages

so that is a bit odd. I would have thought that 5.8.0+ds6-4 should be considered > 5.8

I seem to have got to the bottom of this, or at least got significantly deeper into the hole.
Starting with a clean install of Raspbian Buster node red will install ok from the Raspbian repository, installing nodejs 10.15.2~dfsg-2+rpi1 and npm 5.8.0+ds6-4. However, starting again with a clean install, if one adds the nodesource repository for nodejs 10.x then that makes available nodejs 10.19.0-1nodesource1. Now node red will not install from Raspbian repository. It is not a direct dependency on npm that is the problem, it is much further down the chain of dependencies that there is a conflict, due, I imagine to the way that npm is installed when using the nodesource repository.
Looking at @Lupin_III's screenshot in the first post it can be seen that this cannot be the first time the script was run as it already has nodejs 10.19.0 which must have come from the nodesource repo, then for some reason it was unable to install node-red , but we have not got enough of the original install log to know why. However this happened the result was that the nodesource repo is enabled and once that is done one cannot install node-red from the Raspbian repo.

1 Like

Not quite sure why you would want to install Node-RED from the Rasbian repository? Surely it will always be better to install direct from npmjs?

Also, if installing now and using Buster, why go to nodejs 10? Why not to 12 which is also an LTS release and will be around longer?

a) because it is there and is the only way to get listed in the "available software" list for the Raspbian distro - It used to be pre-installed on the default image - but they have pared that back to the essentials these days. Still is in the "full-install" if anyone uses that... all of which helps "discoverability"...

b) node10 is what buster has by default... debian is very slow at updating - but will no doubt get to 12 (or 14) at some point.

c) yes Node-RED is better installed from the script as that then uses later nodejs etc etc...

I don't, but people do, and when they have problems it is useful to understand the reasons why in order to get them out of a hole.

No I get that, I was just wondering about Colin's approach is all.

Ah, I didn't notice that with my recent build since I always install from the better supported repo as your script also does. So I naturally gravitate to the latest LTS version.

Or do-it-yourself and understand the details :wink: (and yes, I absolutely get that approach is not for everyone).

OK, it wasn't clear from your post I don't think. I didn't want people to become more confused.