Raspian Trixie NodeJS problem

Hi,
After encountering problems with an installation of NodeJS 20, I thought I'd do it properly this time: install NodeJS first, then Node-RED. Unfortunately, the installation script removes the existing version and reinstalls an older version of NodeJS 20. Is there a way to make the script ignore the existing NodeJS 20 installation?


  Stop Node-RED                       ✔
  Remove old version of Node-RED      ✔
  Remove old version of Node.js       ✔   20.19.2+dfsg-1+rpi1
  Install Node 20.19.1-1nodesource1   ✔   v20.19.1   Npm 10.8.2
  Clean npm cache                     ✔
  Install Node-RED core               ✔   4.1.2
  Move global nodes to local          -
  Npm rebuild existing nodes          ✔
  Install extra Pi nodes              ✔
  Add shortcut commands               ✔
  Update systemd script               ✔

Problem: after apt update, there's an issue:

The previously unselected package nodejs-doc is now selected.
Preparing to unpack .../12-nodejs-doc_20.19.2+dfsg-1+rpi1_all.deb ...
Unpacking nodejs-doc (20.19.2+dfsg-1+rpi1) ...
Errors were encountered while processing:
/tmp/apt-dpkg-install-fGsAiu/01-node-corepack_0.24.0-5_all.deb
Error: Sub-process /usr/bin/dpkg returned an error code (1)

I then need to run apt --fix-broken install and rm -f /etc/apt/sources.list.d/nodesource.list to get 20.19.2+dfsg-1+rpi1 back.

Check out the optional parameters on the script.

What does this show?
which node

Run
sudo apt remove nodejs
then check it is gone
node -v
The script should have removed it, but it may be that there is a problem doing that. In which case the above commands may show it.

indeed - the latest version of the script should explicitly test for dfsg versions and remove them in favour of nodesource ones.

but yes - adding --node20 or --node22 to the end of the install command should force it to install a suitable version. If I use --node20 locally I get v20.19.6 which is newer than the dfsg version...

1 Like

I've now installed the script with NodeJS 22 without any problems. NPM: 10.9.2.

With NodeJS 20, the aforementioned problem occurs on Trixies own NodeJS 20.

I don't feel confident enough to manually install Node-RED with: sudo npm install -g --unsafe-perm node-red.
That would leave me with an outdated NPM version (9.x) from Trixie repo.

I think it is the best to install Node-Red with NodeJS 22 on Trixie.

my VM with Ubuntu 24.04LTS is similar: I installed Node-Red with NodeJS 20, the Ubuntu repo would install NodeJS 18 ==> no conflicts.

I would never recommend using a Linux distro's own repositories for node.js, they will often be outdated. Either use Dave's script or use the dedicated node.js repository for your OS. Noting that I believe Dave's script uses the dedicated repository for Debian/Rabian/Ubuntu.

you really don't want to use the default repository for nodejs - it always (IMHO) ends up causing issues - either well behind - or doesn't include npm - or occasionally (as in this instance) appears to be ahead, but includes other weird side packages... Much better to let our install script try to clean it up and install the nodejs nodesource version. (But I would say that :slight_smile: )

I think you are following bad advice.

On a raspberry Pi install the OS, update it then use Dave's script to install npm and Node-red.

I am not sure what version of node.js it installs by default, but you can force a more up to date version by appending --node22.

It does not crop up in the forum very often, but there is a version of the installer for Red Hat based Linuces too.

I think you (all) did not understand the problem.

That's exactly what I've always done, but with Trixie there are problems as described above.

after Node-Red script has finished and you´ll do apt update && upgrade, Trixie reinstalls its own version and mixes corepack and maybe other packages, and this is where the error occurs.

The previously unselected package nodejs-doc is now selected.
Preparing to unpack .../12-nodejs-doc_20.19.2+dfsg-1+rpi1_all.deb ...
Unpacking nodejs-doc (20.19.2+dfsg-1+rpi1) ...
Errors were encountered while processing:
/tmp/apt-dpkg-install-fGsAiu/01-node-corepack_0.24.0-5_all.deb
Error: Sub-process /usr/bin/dpkg returned an error code (1)

I've to choose NodeJS 22 to prevent this.

But is there a solution to prevent apt mixing its 20.19.2+dfsg-1+rpi1 packages into an existing NodeJS20 version (from Node-Red script)??

What I see (on a Pi Zero2, 64 bit OS with Node-red 5 beta) Before:

$ node-red --version
Node-RED v5.0.0-beta.1
Node.js v24.11.1
Linux 6.12.47+rpt-rpi-v8 arm64 LE
 $ sudo apt update && sudo apt -y full-upgrade
...
3 packages can be upgraded. Run 'apt list --upgradable' to see them.
Warning: https://deb.nodesource.com/node_24.x/dists/nodistro/InRelease: Policy will reject signature within a year, see --audit for details
Upgrading:
  libpng16-16t64  nodejs  rpi-eeprom
...
Get:3 https://deb.nodesource.com/node_24.x nodistro/main arm64 nodejs arm64 24.12.0-1nodesource1 [36.9 MB]

After:

 $ node-red --version
Node-RED v5.0.0-beta.1
Node.js v24.12.0
Linux 6.12.47+rpt-rpi-v8 arm64 LE
node-red --version
Node-RED v4.1.2
Node.js v22.15.0
Linux 6.12.47+rpt-rpi-v7 arm LE

what about:

apt-cache policy nodejs
nodejs:
  Installiert:           22.15.0-1nodesource1
  Installationskandidat: 22.15.0-1nodesource1
  Versionstabelle:
 *** 22.15.0-1nodesource1 500
        500 https://deb.nodesource.com/node_22.x nodistro/main armhf Packages
        100 /var/lib/dpkg/status
     22.14.0-1nodesource1 500
        500 https://deb.nodesource.com/node_22.x nodistro/main armhf Packages
     22.13.1-1nodesource1 500
        500 https://deb.nodesource.com/node_22.x nodistro/main armhf Packages
     22.13.0-1nodesource1 500
        500 https://deb.nodesource.com/node_22.x nodistro/main armhf Packages
     22.12.0-1nodesource1 500
        500 https://deb.nodesource.com/node_22.x nodistro/main armhf Packages
     22.11.0-1nodesource1 500
        500 https://deb.nodesource.com/node_22.x nodistro/main armhf Packages
     22.10.0-1nodesource1 500
        500 https://deb.nodesource.com/node_22.x nodistro/main armhf Packages
     22.9.0-1nodesource1 500
        500 https://deb.nodesource.com/node_22.x nodistro/main armhf Packages
     22.8.0-1nodesource1 500
        500 https://deb.nodesource.com/node_22.x nodistro/main armhf Packages
     22.7.0-1nodesource1 500
        500 https://deb.nodesource.com/node_22.x nodistro/main armhf Packages
     22.6.0-1nodesource1 500
        500 https://deb.nodesource.com/node_22.x nodistro/main armhf Packages
     22.5.1-1nodesource1 500
        500 https://deb.nodesource.com/node_22.x nodistro/main armhf Packages
     22.5.0-1nodesource1 500
        500 https://deb.nodesource.com/node_22.x nodistro/main armhf Packages
     22.4.1-1nodesource1 500
        500 https://deb.nodesource.com/node_22.x nodistro/main armhf Packages
     22.4.0-1nodesource1 500
        500 https://deb.nodesource.com/node_22.x nodistro/main armhf Packages
     22.3.0-1nodesource1 500
        500 https://deb.nodesource.com/node_22.x nodistro/main armhf Packages
     22.2.0-1nodesource1 500
        500 https://deb.nodesource.com/node_22.x nodistro/main armhf Packages
     22.1.0-1nodesource1 500
        500 https://deb.nodesource.com/node_22.x nodistro/main armhf Packages
     22.0.0-1nodesource1 500
        500 https://deb.nodesource.com/node_22.x nodistro/main armhf Packages
     20.19.2+dfsg-1+rpi1 500
        500 http://raspbian.raspberrypi.com/raspbian trixie/main armhf Packages

with NodeJS 22 or higher you´ll never get the problem

I misinterpreted that statement as meaning only v22 would work, sorry.

It's a surprise that the install script still defaults to nodejs v20. Maybe for NR v5 it should be bumped to v24?

I have Trixie on several of my Pis and I have never had any problems. I have also updated nodejs to v24, again with no problems, I use

curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash - &&\
sudo apt install -y nodejs

to update.
As has already been said, nodejs v22 can be installed easily with the Node-RED script

It will be... but will drop support for Pi0 and Pi1 as there are no Arm6 builds available

Meanwhile I have found and fixed the underlying nodejs-v20 install issue that was causing grief to the OP. So both node20 (default) and node22 and node24 installs (using the script) should all work OK.

2 Likes

I see you slipped in node24 in there very quietly. I am sure when I tried it not too long ago it wasn't available. :shushing_face:

PS not on the options list

I just upgraded to nodejs-v24 on my rpi4 running Trixie. No issues seen except

Warning: https://deb.nodesource.com/node_24.x/dists/nodistro/InRelease: Policy will reject signature within a year, see --audit for details

I have seen this error on every rpi that I have upgraded to Trixie regardless of the nodejs version.

Running sudo apt update --audit advises:

SHA1 is not considered secure

1 Like

Yes - still testing. Plus as mentioned will no longer support Pi0 or 1 so not pushing 24 yet

This is a known issue with the official node_24 release distribution package. Debian 13 repo issue · Issue #1865 · nodesource/distributions

1 Like

Has anyone tried the work around?