Can't update NR on a RPI ZeroW

After not using NR on a Pi0W, I decided to update everything. No dice.

Running the recommended script:

pi@pizza:~/.node-red $ bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)

Finishes without obvious error (green checkmarks) and tells me to start NR with start-node-red. This yields

Node-RED is not yet fully installed
Fetching Node-RED update.

If I answer "y" at the end, the whole cycle runs again with the same result.
RPI OS: Raspbian Jessie 8
I ran sudo apt update and sudo apt full-upgrade and everything is up to date.

There are some strange entries in the logs.
In /var/log/nodered-install.log we see this:

Started : Mon Nov 19 01:28:08 CST 2018
Running for user pi at /home/pi
Found global nodes: :
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.
npm WARN using --force I sure hope you know what you are doing.
npm ERR! asyncWrite is not a function
npm ERR! pna.nextTick is not a function

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-11-19T07_28_39_932Z-debug.log

> node-red-dashboard@2.8.2 postinstall /home/pi/.node-red/node_modules/node-red-dashboard
> node fixfa.js

> node-red-node-pi-neopixel@0.0.16 postinstall /home/pi/.node-red/node_modules/node-red-node-pi-neopixel
> scripts/checklib.js

Python library found OK.

> node-red-node-pi-sense-hat@0.0.15 postinstall /home/pi/.node-red/node_modules/node-red-node-pi-sense-hat
> scripts/checklib.sh

Sense HAT python library is installed

serialport@6.1.1 install /home/pi/.node-red/node_modules/serialport
prebuild-install || node-gyp rebuild

... and then just some warnings about deprecated modules...

In /root/.npm/_logs/2018-11-19T07_28_39_932Z-debug.log we see this:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node',
1 verbose cli '/usr/bin/npm',
1 verbose cli 'i',
1 verbose cli '-g',
1 verbose cli '--unsafe-perm',
1 verbose cli '--no-progress',
1 verbose cli 'node-red@latest' ]
2 info using npm@6.4.1
3 info using node@v8.12.0
4 verbose npm-session 2290de93fea7561b
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 verbose stack TypeError: asyncWrite is not a function
7 verbose stack at onwrite (/usr/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:480:7)
7 verbose stack at WritableState.onwrite (/usr/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:180:5)
7 verbose stack at WriteStream.to [as _worker] (/usr/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/cache.js:154:13)
7 verbose stack at WriteStream._write (/usr/lib/node_modules/npm/node_modules/mississippi/node_modules/flush-write-stream/index.js:35:13)
7 verbose stack at doWrite (/usr/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:428:64)
7 verbose stack at writeOrBuffer (/usr/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:417:5)
7 verbose stack at WriteStream.Writable.write (/usr/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:334:11)
7 verbose stack at WriteStream.to [as _worker] (/usr/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/cache.js:171:25)
7 verbose stack at WriteStream._write (/usr/lib/node_modules/npm/node_modules/mississippi/node_modules/flush-write-stream/index.js:35:13)
7 verbose stack at doWrite (/usr/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:428:64)
7 verbose stack at writeOrBuffer (/usr/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:417:5)
7 verbose stack at WriteStream.Writable.write (/usr/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:334:11)
7 verbose stack at WriteStream.to [as _worker] (/usr/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/cache.js:182:19)
7 verbose stack at WriteStream._write (/usr/lib/node_modules/npm/node_modules/mississippi/node_modules/flush-write-stream/index.js:35:13)
7 verbose stack at doWrite (/usr/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:428:64)
7 verbose stack at writeOrBuffer (/usr/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:417:5)
8 verbose cwd /home/pi
9 verbose Linux 4.9.35+
10 verbose argv "/usr/bin/node" "/usr/bin/npm" "i" "-g" "--unsafe-perm" "--no-progress" "node-red@latest"
11 verbose node v8.12.0
12 verbose npm v6.4.1
13 error asyncWrite is not a function
14 verbose exit [ 1, true ]
pi@pizza:~/.node-red $

Any suggestions??

Thanks,

--Jeff

This has happened a few times to others for reasons that are not clear, I think. As long as Node-RED is your only node.js application on your pi try

sudo rm -rf /usr/lib/node_modules
sudo rm -rf /usr/bin/node

And re-run the update script

Boom. That did it. Thanks. Whether NR is my only Node.js application is something I can only guess at. But I suspect so, I am only just starting to tinker with js.

Before I call this resolved, running node -v results in v8.12.0.
"Out there on the Internet" I see people running NR on a Pi and they have v10 or v11 installed. On a page with what seems like a lot of good information, I read

The instructions provided here are for installing Node.js on a Pi 3 Model B+ or PI 3 Model B (both running ARMv8) or Pi 2 (ARMv7) rather than other models based on the ARMv6 chip such as the Raspberry Pi 1 Model B, Raspberry Pi Model B+ or the Raspberry Pi Zero. A majority of this installation guide should still prove useful for other Raspberry Pi systems besides the Pi 3 and Pi 2; however, the final steps focused on the installation of Node.js will not work for these systems based on the older ARMv6 architecture.

Running uname -a, I get

Linux pizza 4.9.35+ #1014 Fri Jun 30 14:34:49 BST 2017 armv6l GNU/Linux

So I assume that's what drives the v8.12.0 as opposed to more recent(?) versions.

Is the Node.js version compatibility documented somewhere? Before I asked my question here (and looked at the error logs), I was under the assumption that I was somehow stuck with an ancient, deprecated version.

Final question: During this search, I kept finding references to "n", as if it is a version of Node.js -- what is "n"??

Thanks @Colin

We only want to support Long Term Service versions of Node.js - so 8, 10, 12 etc. - 10 has only just gone to LTS status (Oct) so while probably fine to use (we do test the core against it) - it is just a bit early to fully recommend it - Hence all our docs still recommend Node 8.x. 8.x is in no way deprecated as it is still under support and receiving security patches.

The reason for the hesitation to jump on 10 is in order to let it fully stabilise - there are still other 3rd party plugins and nodes - mostly with binary dependencies - that fail to run under Node 10 and need to be patched and updated.

So yes you are free to update to Node 10 if you wish - and the core nodes should all work fine. The update script will be updated (probably when we release our version 0.20.0) - but that will only install Node10 for new installs, it will leave Node8 in place so as to (hopefully) not break anyone.

n - is a way of running nodejs ( https://github.com/tj/n ) - that allows you to switch from one version to another very easily - great for development and testing things - but not easy for us to support as a way of running - so if you do then you will need to look after binary module rebuilds and so on yourself as the script probably won't get it right.

@dceejay Thank you for taking time to read all the way to the bottom (NTL;DR - not too long, did read). I know a bit more today than I did yesterday. Which is sort of the objective, eh?

Cheers!