Updating things and what I'm seeing

From my other thread: Stuck with how to resolve this problem (Global context testing) - #22 by Trying_to_learn

@TotallyInformation

sudo apt update && sudo apt upgrade
sudo npm -g update
cd ~/.node-red
npm update

You can see here I have done the first line and am doing the second one.

pi@TimePi:~ $ sudo apt upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following package was automatically installed and is no longer required:
  libdav1d3
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
pi@TimePi:~ $ sudo npm -g update
npm ERR! code EEXIST
npm ERR! path /usr/bin/corepack
npm ERR! Refusing to delete /usr/bin/corepack: ../lib/node_modules/corepack/dist/corepack.js symlink target is not controlled by npm /usr/lib/node_modules/corepack
npm ERR! File exists: /usr/bin/corepack
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2024-09-29T01_01_42_577Z-debug.log
pi@TimePi:~ $ 

Is it I am doing things in the wrong order?
I have (as yet) NOT updated anything else.

You might want to check what has installed corepack. sudo npm -g ls corepack should do that. Does it really need to be a global install?

It seems that /usr/bin/corepack may have some odd permissions on it. Try removing it by hand before re-running the update.

Nope.

(Thanks)

pi@TimePi:~ $ sudo npm -g ls corepack
/usr/lib
└── corepack@0.15.1 



   ╭────────────────────────────────────────────────────────────────╮
   │                                                                │
   │      New major version of npm available! 6.14.18 → 10.8.3      │
   │   Changelog: https://github.com/npm/cli/releases/tag/v10.8.3   │
   │               Run npm install -g npm to update!                │
   │                                                                │
   ╰────────────────────────────────────────────────────────────────╯

pi@TimePi:~ $

So I'll do as suggested?
npm install -g npm

Ok, I had to sudo it and it worked.

pi@TimePi:~ $ sudo npm install -g npm
/usr/bin/npm -> /usr/lib/node_modules/npm/bin/npm-cli.js
/usr/bin/npx -> /usr/lib/node_modules/npm/bin/npx-cli.js
npm WARN notsup Unsupported engine for npm@10.8.3: wanted: {"node":"^18.17.0 || >=20.5.0"} (current: {"node":"14.21.3","npm":"6.14.18"})
npm WARN notsup Not compatible with your version of node/npm: npm@10.8.3

+ npm@10.8.3
added 88 packages from 24 contributors, removed 345 packages and updated 113 packages in 46.071s
pi@TimePi:~ $ 

Hmmm..

pi@TimePi:~/.node-red $ npm update
ERROR: npm v10.8.3 is known not to run on Node.js v14.21.3.  This version of npm supports the following node versions: `^18.17.0 || >=20.5.0`. You can find the latest version at https://nodejs.org/.

ERROR:
/usr/lib/node_modules/npm/lib/utils/error-message.js:11
  er.message &&= replaceInfo(er.message)
             ^^^

SyntaxError: Unexpected token '&&='
    at wrapSafe (internal/modules/cjs/loader.js:1029:16)
    at Module._compile (internal/modules/cjs/loader.js:1078:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
    at Module.load (internal/modules/cjs/loader.js:979:32)
    at Function.Module._load (internal/modules/cjs/loader.js:819:12)
    at Module.require (internal/modules/cjs/loader.js:1003:19)
    at require (internal/modules/cjs/helpers.js:107:18)
    at Object.<anonymous> (/usr/lib/node_modules/npm/lib/cli/exit-handler.js:2:48)
    at Module._compile (internal/modules/cjs/loader.js:1114:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
pi@TimePi:~/.node-red $ 

Why are you trying to upgrade npm? npm comes with nodejs, there should be no need to upgrade it manually.

Ah, I see, @TotallyInformation suggested that route. I think he was assuming that you did not use the usual install/upgrade script to install node red and nodejs. The update is failing because you have not updated nodejs first.

As I said in your original thread, just use the usual install/upgrade script to update node red and nodejs. Add --node20 on the end if you want to go to v20, which is probably a good idea. That will do everything you need.