Pi: Lost Palette manager, can't update

Oh, god! I’m contagious! :joy:

What do you see for

node -v
npm -v

and what sort of pi is it?

I see the same as before:

pi@raspberrypi:~ $ node -v
pi@raspberrypi:~ $ npm -v
ERROR: npm is known not to run on Node.js v4.2.1
Node.js 4 is supported but the specific version you're running has
a bug known to break npm. Please update to at least 4.7.0 to use this
version of npm. You can find the latest release of Node.js at https://nodejs.org/
pi@raspberrypi:~ $

And it's a 3B, the latest version. But I tried the same image in a Pi 1, and I had the same result there.

Edit: And I did not use the same image again on the 3B, both were copies of the image on the production Pi.

What do you see for

apt-cache policy nodejs
apt-cache policy npm
ls /etc/apt/sources.list.d

and if the last shows a file whose name has something like nodesource in it then

cat /etc/apt/sources.list.d/whatever-the-file-is-called
pi@raspberrypi:~ $ apt-cache policy nodejs
  Installed: 6.14.3-1nodesource1
  Candidate: 6.14.3-1nodesource1
  Version table:
 *** 6.14.3-1nodesource1 500
        500 https://deb.nodesource.com/node_6.x stretch/main armhf Packages
        100 /var/lib/dpkg/status
     4.8.2~dfsg-1 500
        500 http://raspbian.raspberrypi.org/raspbian stretch/main armhf Packages
pi@raspberrypi:~ $ apt-cache policy npm
  Installed: (none)
  Candidate: 1.4.21+ds-2
  Version table:
     1.4.21+ds-2 500
        500 http://raspbian.raspberrypi.org/raspbian stretch/main armhf Packages
pi@raspberrypi:~ $ ls /etc/apt/sources.list.d
nodesource.list  raspi.list
pi@raspberrypi:~ $ cat /etc/apt/sources.list.d/whatever-the-file-is-called
cat: /etc/apt/sources.list.d/whatever-the-file-is-called: No such file or directory
pi@raspberrypi:~ $ cat /etc/apt/sources.list.d/nodesource.list
deb https://deb.nodesource.com/node_6.x stretch main
deb-src https://deb.nodesource.com/node_6.x stretch main
pi@raspberrypi:~ $ 

And yes, the second to last command is meant as a joke! :wink:

That is not what I expected, it says nodejs 6.14.3 is installed but you said node -v showed node 4. Can you just check that for me and say what which node shows.

It still says v4.2.1 when I run node -v.

You didn’t say what the command which node shows.

Oh, sorry. This was not a joke… This was me being an ididot. /usr/local/bin/node

That’s it. Somehow you have installed a local copy of node. No idea how. Now we need to get rid of it, what do you see for

ls -l /usr/local/bin/node*
ls -l /usr/local/bin/npm*

Just want to check what is there before deleting it.

Fantastic that you were able to find out that! :slight_smile: I see that it goes far back, it's on all my production Pi's.

pi@raspberrypi:~ $ ls -l /usr/local/bin/node*
-rwxr-xr-x 1 root staff 11949036 Oct 17 2015 /usr/local/bin/node
pi@raspberrypi:~ $ ls -l /usr/local/bin/npm*
lrwxrwxrwx 1 root root 38 Apr 21 18:03 /usr/local/bin/npm -> ../lib/node_modules/npm/bin/npm-cli.js
pi@raspberrypi:~ $

It’s been there since before I installed Home Assistant, so it’s a very long time.

Ok, lets get rid of those and try again. I can’t remember what state npm is in so lets use the sledgehammer again.

sudo rm /usr/local/bin/node*
sudo rm /usr/local/bin/npm*
sudo apt-get remove nodejs npm
sudo rm /etc/apt/sources.list.d/nodesource.list
sudo rm /usr/bin/node*
sudo rm /usr/bin/npm*
sudo rm /var/log/nodered-install.log

The last is to remove all the old install log contents as it adds to it each time.
Then run the bash <(curl command again.
If it fails again at the same point paste the log here, it should be shorter this time.

I think you’re really on to something now! :slight_smile: But something is not fully done, this is what I got:

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

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       ✔
  Install Node.js LTS                 ✔   Node v8.11.3   Npm 5.6.0
  Clean npm cache                     ✔
  Install Node-RED core               ✔   
  Move global nodes to local          -
  Install extra Pi nodes              -
  Npm rebuild existing nodes          ✔
  Add menu shortcut                   ✔
  Update systemd script               ✔
  Update update script                ✔

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

All done.
  You can now start Node-RED with the command  node-red-start
  or using the icon under   Menu / Programming / Node-RED
  Then point your browser to localhost:1880 or http://{your_pi_ip-address}:1880

Started  Wed Jun 20 12:13:22 CEST 2018  -  Finished  Wed Jun 20 12:15:52 CEST 2018

pi@raspberrypi:~ $ node-red-start

Node-RED is not yet fully installed

Fetching Node-RED update.

This script will remove versions of Node.js prior to version 6.x, and Node-RED and
if necessary replace them with Node.js 8.x LTS (carbon) and the latest Node-RED from Npm.
It also moves any Node-RED nodes that are globally installed into your user
~/.node-red/node_modules directory, and adds them to your package.json, so that
you can manage them with the palette manager.
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.
Are you really sure you want to do this ? [y/N] ?

My guess is that I am really sure I want to do this. :wink:

Yeah, I really wanted to do this! Now it works, I have Palette manager back! Thanks a lot for your help, sir! Now I will do the same process (removing the local node.js copy and update) a copy of each of the production images and run them.

1 Like

Excellent. It should not really have taken me as long to realise what was happening. The clues were there.

For you, maybe. For me? More like black magic with all these commands and weird directories. I was pretty good at DOS 3.22, but I guess I have forgotten a lot of that… Thanks again for the help!

The odd thing about this is that the bash update script should automatically look in /usr/local (and remove any old node.js in there) if run as per the docs.

Well, the odd is sort of my signature… :wink: Sort of like a walkingf Murphy’s law - if anything can go wrong, it will go wrong for me!