Upgrade on raspberry pi failed

So, I was using the recommended method for upgrading node-red on my raspberry pi:
but it failed to install nodejs for armv6. looking at the log I see this:

log.progressEnabled = log.gauge.isEnabled()

TypeError: log.gauge.isEnabled is not a function
    at Object.<anonymous> (/usr/lib/node_modules/npm/node_modules/npmlog/log.js:57:33)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at /usr/lib/node_modules/npm/bin/npm-cli.js:22:13
    at Object.<anonymous> (/usr/lib/node_modules/npm/bin/npm-cli.js:153:3)

Oh, interesting. Looks like I have node V10.15.0 but when I try to run npm -v I get the error above.

Others in simlar situations have found that running the following commands to forcefully remove node and npm and then running the upgrade script, works for them. Note that if you use node.js for things other than node red then you might not want to do this as it removes all globally installed nodes. The node red install will put back the ones it needs but not others.

cd /usr/lib
sudo rm -rf node_modules
cd ~
sudo rm /usr/bin/node
sudo rm /usr/bin/npm

Note, be very careful, particularly with the rm -rf command. Some suggest using sudo rm -rf /usr/lib/node_modules but I prefer to cd to /usr/lib then run the command on node_modules. The reason is that with the former command, if one accidentally put a space after the first / then it becomes a command that would completely remove everything from / downwards, so deleting your complete system.

1 Like