Updating, nodejs, and other things

Sorry the top part somehow got lost.

Hit:1 http://raspbian.raspberrypi.org/raspbian stretch InRelease                 
Hit:2 http://archive.raspberrypi.org/debian stretch InRelease                    
Reading package lists... Done                      
Building dependency tree       
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
pi@PortaPi:~/.node-red $ bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) --node18

 
This script checks the version of node.js installed is 14 or greater. It will try to
install node 16 if none is found. It can optionally install node 12, 14, 16 or 18 LTS for you.
 
If necessary it will then remove the old core of Node-RED, before then installing the latest
version. You can also optionally specify the version required.
 
It also tries to run 'npm rebuild' to refresh any extra nodes you have installed
that may have a native binary component. While this normally works ok, you need
to check that it succeeds for your combination of installed nodes.
 
To do all this it runs commands as root - please satisfy yourself that this will
not damage your Pi, or otherwise compromise your configuration.
If in doubt please backup your SD card first.
 
See the optional parameters by re-running this command with --help
 
Are you really sure you want to do this ? [y/N] ? y

Would you like to install the Pi-specific nodes ? [y/N] ? n


Running Node-RED update for user pi at /home/pi on raspbian


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       ✔   v8.17.0
  Install Node.js 18 LTS              ✘   Bad install:  Node.js missing  Npm missing - Exit
  Clean npm cache                     
  Install Node-RED core               
  Move global nodes to local          
  Npm rebuild existing nodes          
  Install extra Pi nodes              
  Add shortcut commands               
  Update systemd script               
                                      

Any errors will be logged to   /var/log/nodered-install.log

pi@PortaPi:~/.node-red $ 

Ok, sorry to include:
This is what the files in the repository directory.

i@PortaPi:/etc/apt/sources.list.d $ cat *
deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x stretch main
deb-src [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x stretch main
#deb http://q4os.org/qextrepo q4os-rpi-firefox-cn main
deb http://archive.raspberrypi.org/debian/ stretch main ui
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://archive.raspberrypi.org/debian/ stretch main ui
pi@PortaPi:/etc/apt/sources.list.d $ 

You have got past the update/upgrade so that is ok. I wonder if there is not a nodejs 18 for stretch. Try the script with --node14.

1 Like

Thanks.

That's looking better.

I caught the --node14... :wink:

It got to there and stopped - waiting.

waiting and waiting.

I'll post when the next thing happens.

(and of course) as I pressed it continued.
Down to installing node-red core

Looking a lot better.

Thanks Colin.

Running now.

(But I haven't checked the version numbers. I'll hope that they are ok now.)

It would be worth trying 16.

(I'm not sure I should push my luck getting 14 working.) :wink:

Maybe when I do the next machine I will try it with 16.

no, you should try now. Node14 is END OF LIFE

Node 16 will be soon, but at least it is still valid.

Also, if it fails, just run it with --node14 once more!


NOTE: node18 requires ubuntu > stretch (but it can be compiled to run on stretch)

The real solution is to upgrade the OS to buster, or better

1 Like

If it fails you just have to run it again with 14.

Ok. So back to the command with --node16 on the end - yes?
(sorry)

Yes. --node16
Though as Steve says, you need to think about upgrading the pi.

Yeah. I probably should. Just they don't get used much/often.

It is a is it worth the time now? for how often they get used.

But point taken.

:frowning:
Hmmm..... Doesn't like that.

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) --node16

Gives:

Running Node-RED update for user pi at /home/pi on raspbian


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       ✔   v14.21.3
  Install Node.js 18 LTS              ✘   Bad install:  Node.js missing  Npm missing - Exit

Checking log

Started : Mon 14 Aug 19:01:58 AEST 2023
Running for user pi at /home/pi
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...
Package 'nodered' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Installing nodejs 18

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

Reading package lists...
Building dependency tree...
Reading state information...
Package 'nodejs-legacy' is not installed, so not removed
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, 115 MB disk space will be freed.
(Reading database ... 125074 files and directories currently installed.)
Removing nodejs (14.21.3-1nodesource1) ...
dpkg: warning: while removing nodejs, directory '/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator' not empty so not removed
Processing triggers for man-db (2.7.6.1-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.52.1-5+deb9u16).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

## Installing the NodeSource Node.js 18.x repo...


## Populating apt-get cache...

+ apt-get update
Hit:1 http://raspbian.raspberrypi.org/raspbian stretch InRelease
Hit:2 http://archive.raspberrypi.org/debian stretch InRelease
Hit:3 https://deb.nodesource.com/node_14.x stretch InRelease
Reading package lists...

## Confirming "stretch" is supported...

+ curl -sLf -o /dev/null 'https://deb.nodesource.com/node_18.x/dists/stretch/Release'

## Adding the NodeSource signing key to your keyring...

+ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | tee /usr/share/keyrings/nodesource.gpg >/dev/null
gpg: WARNING: unsafe ownership on homedir '/home/pi/.gnupg'

## Creating apt sources list file for the NodeSource Node.js 18.x repo...

+ echo 'deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x stretch main' > /etc/apt/sources.list.d/nodesource.list
+ echo 'deb-src [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x stretch main' >> /etc/apt/sources.list.d/nodesource.list

## Running `apt-get update` for you...

+ apt-get update
Hit:1 http://raspbian.raspberrypi.org/raspbian stretch InRelease
Hit:2 http://archive.raspberrypi.org/debian stretch InRelease
Get:3 https://deb.nodesource.com/node_18.x stretch InRelease [4,585 B]
Get:4 https://deb.nodesource.com/node_18.x stretch/main armhf Packages [783 B]
Fetched 5,368 B in 3s (1,769 B/s)
Reading package lists...

## Run `sudo apt-get install -y nodejs` to install Node.js 18.x and npm
## You may also need development tools to build native addons:
     sudo apt-get install gcc g++ make
## To install the Yarn package manager, run:
     curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
     echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
     sudo apt-get update && sudo apt-get install yarn



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

Reading package lists...
Building dependency tree...
Reading state information...
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 nodejs : Depends: libc6 (>= 2.28) but 2.24-11+deb9u4 is to be installed
E: Unable to correct problems, you have held broken packages.

Versions: node:missing npm:missing

This is the last part - as I can make.
EDITED - the complete part now included.

Are you sure you said --node16, the output looks as if you said 18 again.

Well, yes.

That threw me a curve ball.

I copied/pasted from the terminal.

I'm now doing another old machine.

I'll try it with --node16 and see what happens.

Be back soon.

Yes what? You did use 16 or you didn't use 16?

pi@BeefPi:~ $ cd .node-red
pi@BeefPi:~/.node-red $ bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) --node16

 
This script checks the version of node.js installed is 14 or greater. It will try to
install node 18 if none is found. It can optionally install node 16, 18 or 20 LTS for you.
 
If necessary it will then remove the old core of Node-RED, before then installing the latest
version. You can also optionally specify the version required.
 
It also tries to run 'npm rebuild' to refresh any extra nodes you have installed
that may have a native binary component. While this normally works ok, you need
to check that it succeeds for your combination of installed nodes.
 
To do all this it runs commands as root - please satisfy yourself that this will
not damage your Pi, or otherwise compromise your configuration.
If in doubt please backup your SD card first.
 
See the optional parameters by re-running this command with --help
 
Are you really sure you want to do this ? [y/N] ? y

Would you like to install the Pi-specific nodes ? [y/N] ? 

Getting:

Running Node-RED update for user pi at /home/pi on raspbian

n
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       ✔   v12.21.0
  Install Node.js 18 LTS              ✘   Bad install:  Node.js missing  Npm missing - Exit
  Clean npm cache                     
  Install Node-RED core               
  Move global nodes to local          
  Npm rebuild existing nodes          
  Install extra Pi nodes              
  Add shortcut commands               
  Update systemd script               
                                      

Any errors will be logged to   /var/log/nodered-install.log

pi@BeefPi:~/.node-red $ 

Dunno why it is showing 18 though.
But as you can see I did do --node16

Well that is very strange, I will try and investigate later. You had better stick to 14 for your stretch systems for the moment.

FOUND SOMETHING THAT MAY BE OF IMPORTANCE

I looked at the install script that is run.

exert:

 else
            if [[ "$NODE_VERSION" == "12" ]]; then
                tgtl=$tgtl12
                tgta=$tgta12
            elif [[ "$NODE_VERSION" == "14" ]]; then
                tgtl=$tgtl14
                tgta=$tgta14
            elif [[ "$NODE_VERSION" == "18" ]]; then
                tgtl=$tgtl18
                tgta=$tgta18
            elif [[ "$NODE_VERSION" == "20" ]]; then
                tgtl="None"
                tgta=$tgta20

There is no option for 16,
So I guess it falls through to 18 - which is why 18 was shown in the line
Install Node.js ## LTS

Though if 16 is now gone, does it really matter?

Well diagnosed!

@dceejay is this a bug in the install script?

1 Like

Thanks.... (blush)

I just looked at how it worked and tried to understand how/why it was doing that.