Pi install nodejs question

I have just run the bash <(curl... script to install node-red on a pi-zero running raspbian lite. It is all working ok but I am confused by something.
The first time round I got stuck in the node-Red not fully installed loop wanting to run re-run the script so I removed /usr/lib/node_modules and usr/bin/node, checked that node -v showed command not found and re-ran the script, and all seems to be working ok. However I am confused about how nodejs has been installed. I see

$ node -v
v10.15.3
$ npm -v
6.9.0
$ which node
/usr/bin/node
$ which npm
/usr/bin/npm

which looks fine, but I also see

$ apt-cache policy nodejs
nodejs:
  Installed: (none)
  Candidate: 8.11.1~dfsg-2~bpo9+1
  Version table:
     8.11.1~dfsg-2~bpo9+1 500
        500 http://archive.raspberrypi.org/debian stretch/main armhf Packages
     4.8.2~dfsg-1 500
        500 http://raspbian.raspberrypi.org/raspbian stretch/main armhf Packages

and there is no nodesource repo in /etc/apt/sources.list.d so I don't understand how node has been installed.

During the script it showed

  Stop Node-RED                       ✔
  Remove old version of Node-RED      ✔
  Remove old version of Node.js       ✔
  Install Node.js for Armv6           ✔   Node v10.15.3   Npm 6.9.0
  Clean npm cache                     ✔
  Install Node-RED core               ✔   0.19.6 
  Move global nodes to local          -
  Install extra Pi nodes              -
  Npm rebuild existing nodes          -
  Add shortcut commands               ✔
  Update systemd script               ✔

The relevant section of the install log has

Package 'nodejs-legacy' is not installed, so not removed
Package 'npm' is not installed, so not removed
Package 'nodejs' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
dpkg: warning: ignoring request to remove nodejs which isn't installed
dpkg: warning: ignoring request to remove node which isn't installed
Reading package lists...
Building dependency tree...
Reading state information...
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
/usr/bin/npm -> /usr/lib/node_modules/npm/bin/npm-cli.js
/usr/bin/npx -> /usr/lib/node_modules/npm/bin/npx-cli.js
+ npm@6.9.0
added 54 packages from 9 contributors, removed 15 packages and updated 47 packages in 372.011s

So the question is, how has nodejs been installed?

See:

The relevant lines are currently 28 & 29

Sorry, I am missing something. How does that relate to the fact that apt-cache policy nodejs says it is not installed, and in the pi install script I see

if curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - 2>&1 | sudo tee -a /var/log/nodered-install.log >>/dev/null; then CHAR=$TICK; else CHAR=$CROSS; fi

which I thought was adding the nodesource repository so nodejs could be installed from there.

I've never used the apt-cache policy nodejs command and I don't know what it does. As I don't use Dave's excellent script, my Pi's look different:

pi@pi3:~/nrlive $ apt-cache policy nodejs
nodejs:
  Installed: 8.15.1-1nodesource1
  Candidate: 8.15.1-1nodesource1
  Version table:
 *** 8.15.1-1nodesource1 500
        500 https://deb.nodesource.com/node_8.x stretch/main armhf Packages
        100 /var/lib/dpkg/status
     8.11.1~dfsg-2~bpo9+1 100
        100 http://ftp.debian.org/debian stretch-backports/main armhf Packages
     8.11.1~dfsg-2~bpo9+1 500
        500 http://archive.raspberrypi.org/debian stretch/main armhf Packages
     4.8.2~dfsg-1 500
        500 http://raspbian.raspberrypi.org/raspbian stretch/main armhf Packages

As you can see, I install direct from the nodesource library. Which, as you say, Dave's script is also doing.

the magic words in the OP are "on a pi-zero"...
the Pi0 is an Arm6 device which the nodesource guys don't support ( see https://github.com/nodesource/distributions#deb) so the magic is here instead - https://github.com/node-red/raspbian-deb-package/blob/master/resources/update-nodejs-and-nodered#L183 - ie I get the version direct from nodejs.org and just unpack it.

Also as This method does NOT use apt - then the apt-cache will say a) that it's isn't installed and b) that the version available is 8.11 (or whatever)... This is an ongoing issue with Debian and one of the reasons the pre-built Pi package is recommended to be updated as soon as you can :slight_smile:

Ah, ok, thanks.

I don't think you are right about not using apt on a non-zero pi. Having fetched the nodesource repo the script uses apt to install from there, so on a pi 3 it shows something like

$ apt-cache policy nodejs
nodejs:
  Installed: 8.12.0-1nodesource1
  Candidate: 8.15.1-1nodesource1
  Version table:
     8.15.1-1nodesource1 0
        500 https://deb.nodesource.com/node_8.x/ jessie/main armhf Packages
 *** 8.12.0-1nodesource1 0
        100 /var/lib/dpkg/status
     0.10.29~dfsg-2 0
        500 http://mirrordirector.raspbian.org/raspbian/ jessie/main armhf Packages

That one is still on Jessie, but I don't think that has changed.
At which point I notice that this pi is out of date.

Sorry, corrected above.