It is clear, why Node RED failed to install.
See the second and third line in the screen.
I had the same issue, while trying to install NR 4.0.2 on a Rasberry Pi 1 B with Rasberry Pi OS Buster.
See: Can't start node-red 4 after re-install on pi zero w - #9 by blooders
Try to install with the --node18 option
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) --node18