The tail of the install log when script failure is observed is
WARNING: apt does not have a stable CLI interface yet. 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: libstdc++6 (>= 5.2) but 4.9.2-10 is to be installed
E: Unable to correct problems, you have held broken packages.
sudo: npm: command not found
Earlier in the the log I see:
## Run `sudo apt-get install -y nodejs` to install Node.js 12.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 | sudo apt-key add -
echo "deb 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
So node at the 12.x level is being tried and apparently this is too new for Jessie.
I am not starting with a clean Jessie unfortunately and for the class I am running, the students are using this "unlcean" Jessie.
I get the same error condition:
Reading package lists...
## Run `sudo apt-get install -y nodejs` to install Node.js 12.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 | sudo apt-key add -
echo "deb 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 yet. 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: libstdc++6 (>= 5.2) but 4.9.2-10 is to be installed
E: Unable to correct problems, you have held broken packages.
sudo: npm: command not found
Reading package lists...
## You seem to be using Devuan version jessie.
## This maps to Debian "jessie"... Adjusting for you...
## Confirming "jessie" is supported...
+ curl -sLf -o /dev/null 'https://deb.nodesource.com/node_12.x/dists/jessie/Release'
## Adding the NodeSource signing key to your keyring...
+ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
OK
## Creating apt sources list file for the NodeSource Node.js 12.x repo...
+ echo 'deb https://deb.nodesource.com/node_12.x jessie main' > /etc/apt/sources.list.d/nodesource.list
+ echo 'deb-src https://deb.nodesource.com/node_12.x jessie main' >> /etc/apt/sources.list.d/nodesource.list
Glad to report that the script succeeds the first time now.
I guess node was so old that the file /etc/apt/sources.list.d/nodesource.list did not exist initially but after a failed install, that location did resolve and so the selection of the 10.x version applied.
pi@raspberrypi:~ $ sudo apt-get install -y nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
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: libstdc++6 (>= 5.2) but 4.9.2-10+deb8u2 is to be installed
E: Unable to correct problems, you have held broken packages.
pi@raspberrypi:~
Debian Jessie is beyond end of life and not getting fixes so you may have to find an older installer for node.js. Or maybe try a tgz version and manually unpack it.
Best option would be to upgrade Debian.