Install script node<version> fails

I had installed a new server with nodejs, happened to be node 19.x, so I figured if I install NR with the --node16 option, it would uninstall v19 and install v16, but the install script states:

This can take 20-30 minutes on the slower Pi versions - please wait.

  Stop Node-RED                       ✔
  Remove old version of Node-RED      ✔
  Remove old version of Node.js       ✔   v19.0.1
  Install Node.js 16 LTS              ✔   v19.0.1   Npm 8.19.2
  Clean npm cache                     ✔
  Install Node-RED core               ✔   3.0.2
  Move global nodes to local          -
  Npm rebuild existing nodes          ✔
  Install extra Pi nodes              -
  Add shortcut commands               ✔
  Update systemd script               ✔

Is this correct ?

No, it has failed to remove nodejs 19 and replace it with 16. How did you install v19 originally?

Also post the install log please. /var/log/nodered-install.log. Or look at it to see what it says about nodejs.

Actually, first check that this works without error
sudo apt update
sudo apt full-upgrade
If it does anything then try the script again. If it still fails then what does
apt policy nodejs
say?

The install log:

Started : Fri 11 Nov 2022 10:47:04 AM CET
Running for user administrator at /home/administrator
Found global nodes:   :

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package nodered
Installing nodejs 16

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
Package 'npm' is not installed, so not removed
The following packages will be REMOVED:
  nodejs
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 183 MB disk space will be freed.
(Reading database ...

Removing nodejs (19.0.1-deb-1nodesource1) ...
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules' not empty so not removed
Processing triggers for man-db (2.9.4-2) ...
dpkg: warning: ignoring request to remove nodejs which isn't installed
dpkg: warning: ignoring request to remove node which isn't installed

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Grab the LTS bundle

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
curl is already the newest version (7.74.0-1.3+deb11u3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
  nodejs
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/29.0 MB of archives.
After this operation, 183 MB of additional disk space will be used.
Selecting previously unselected package nodejs.
(Reading database ...

Preparing to unpack .../nodejs_19.0.1-deb-1nodesource1_amd64.deb ...
Unpacking nodejs (19.0.1-deb-1nodesource1) ...
Setting up nodejs (19.0.1-deb-1nodesource1) ...
Processing triggers for man-db (2.9.4-2) ...

Versions: node:v19.0.1 npm:8.19.2
npm WARN using --force Recommended protections disabled.
Now install Node-RED

added 292 packages in 22s
3.0.2
Now create basic package.json for the user and move any global nodes
Running npm rebuild
rebuilt dependencies successfully
Now add the shortcut and start/stop/log scripts to the menu
Now add systemd script and configure it for administrator:administrator @ /home/administrator
ln: failed to create symbolic link '/usr/bin/python': File exists
Now add launcher to top bar, add cpu temp example, make sure ping works
Allow binding to low ports : n
Memory  : 8.6G
Started :  Fri 11 Nov 2022 10:47:04 AM CET
Finished:  Fri 11 Nov 2022 10:47:43 AM CET
Already have nodejs v19.0.1
OLD nodejs 19 :
NEW nodejs 16 :

I manually removed nodejs and reinstalled 16 instead.

How did you do that?

@dceejay can you make any sense of the log above? It appears to say that it going to remove nodejs 19, but then says it isn't installed, and then goes on to install it again.

@bakman2 what OS/version are you using?

Odd indeed - I'll try to give node19 a whirl tomorrow. (Of course we don't support non-LTS versions but it should be able to remove it :-)...
Of course you could try to sudo apt purge nodejs outside of the script - then use which node to check it has gone - then remove any /etc/apt/sources.list.d/nodesource.list file - then re-run the script...

@Colin

How did you do that?

I did the removal after this initial post, using some guide i found online.

what OS/version are you using?

Debian 11

Hmm - so - I installed node19.0.1 from nodejs.org on my Pi3... then ran the script with --node16 added. and no surprises here...

pi@pi3:~ $ node -v
v16.18.1

For good measure, don't know if it makes a difference:

I had a clean debian 11 install.
Installed nodejs (turned out to be v19)
Installed NR with the script (no options)
Some flows/nodes failed to work.

Re-ran the script with the --node16 option

On what hardware. Which exact Debian installer ?

In a VM - default debian netinstall iso

$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

$ uname -a
Linux core 5.10.0-19-amd64 #1 SMP Debian 5.10.149-2 (2022-10-21) x86_64 GNU/Linux

VM. . On what architecture ?

Not sure what you mean with architecture, but this is running on Proxmox with KVM/QEMU - x86.

X86 ? Or i64 ?

The debian version is amd64 (?)

I can try to replicate it, maybe something with nodejs got borked somewhere in the process.

Depends if nodejs 19 came from the default repo (which I don’t think it does in Debian, as they lag terribly so would be 12 most likely).

How did you install nodejs?

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