Closed thinkbig1979 closed 5 months ago
Can you show the content of the log file:
cat /mnt/dietpi_userdata/node-red/.npm/_logs/2024-06-25T11_23_57_442Z-debug-0.log
Sure, here you go:
~ ❯ cat /mnt/dietpi_userdata/node-red/.npm/_logs/2024-06-25T11_23_57_442Z-debug-0.log
0 verbose cli /usr/local/bin/node /usr/local/bin/npm
1 info using npm@10.8.1
2 info using node@v22.3.0
3 silly config load:file:/usr/local/lib/node_modules/npm/npmrc
4 silly config load:file:/mnt/dietpi_userdata/node-red/.npmrc
5 silly config load:file:/usr/local/etc/npmrc
6 verbose title npm i node-red
7 verbose argv "i" "--no-audit" "node-red"
8 verbose logfile logs-max:10 dir:/mnt/dietpi_userdata/node-red/.npm/_logs/2024-06-25T11_23_57_442Z-
9 verbose logfile /mnt/dietpi_userdata/node-red/.npm/_logs/2024-06-25T11_23_57_442Z-debug-0.log
10 silly logfile start cleaning logs, removing 2 files
11 verbose stack TypeError: Class extends value undefined is not a constructor or null
11 verbose stack at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/minipass-collect/index.js:4:23)
11 verbose stack at Module._compile (node:internal/modules/cjs/loader:1460:14)
11 verbose stack at Module._extensions..js (node:internal/modules/cjs/loader:1544:10)
11 verbose stack at Module.load (node:internal/modules/cjs/loader:1275:32)
11 verbose stack at Module._load (node:internal/modules/cjs/loader:1091:12)
11 verbose stack at wrapModuleLoad (node:internal/modules/cjs/loader:212:19)
11 verbose stack at Module.require (node:internal/modules/cjs/loader:1297:12)
11 verbose stack at require (node:internal/modules/helpers:123:16)
11 verbose stack at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/cacache/lib/get.js:3:17)
11 verbose stack at Module._compile (node:internal/modules/cjs/loader:1460:14)
12 error Class extends value undefined is not a constructor or null
13 verbose cwd /mnt/dietpi_userdata/node-red
14 verbose os Linux 6.1.21-v7+
15 verbose node v22.3.0
16 verbose npm v10.8.1
17 verbose exit 1
18 verbose code 1
19 error A complete log of this run can be found in: /mnt/dietpi_userdata/node-red/.npm/_logs/2024-06-25T11_23_57_442Z-debug-0.log
Hmm, npm
does a pretty bad job resolving conflicts between global and local modules. Looks like the minipass-collect
(which is part of the Node.js core installation) is too new for some of the locally installed Node-RED dependencies. I just do not get why this matters when one explicitly asks to install=update those local modules. However, you are not the first one who runs into such issue, when upgrading from certain older Node-RED versions. So let's solve this once and for all.
Can you test this:
cd /mnt/dietpi_userdata/node-red
sudo -u nodered npm i --no-audit node-red@latest
And if it does not work, this:
cd /mnt/dietpi_userdata/node-red
sudo -u nodered npm up --no-audit node-red
The hammer method is to remove all local modules and install them freshly. But if one of the above works, I would prefer it, causing less traffic and disk I/O:
cd /mnt/dietpi_userdata/node-red
sudo rm -R node_modules
npm i --no-audit node-red
EDIT: Ah, the last one is bad, because it removes all manually installed Node-RED plugins as well.
Tested the first 2 options:
/mnt/dietpi_userdata/node-red ❯ sudo -u nodered npm i --no-audit node-red@latest
npm error Class extends value undefined is not a constructor or null
npm error A complete log of this run can be found in: /mnt/dietpi_userdata/node-red/.npm/_logs/2024-06-25T14_11_26_351Z-debug-0.log
/mnt/dietpi_userdata/node-red ❯ sudo -u nodered npm up --no-audit node-red
npm error Class extends value undefined is not a constructor or null
npm error A complete log of this run can be found in: /mnt/dietpi_userdata/node-red/.npm/_logs/2024-06-25T14_11_59_706Z-debug-0.log
Will look into the third option asap. First want to make sure I do not have any manually installed stuff that could trip the installation up.
First want to make sure I do not have any manually installed stuff that could trip the installation up.
Actually, when plugins were installed manually, they should show up in /mnt/dietpi_userdata/node-red/package.json
. Can you test this first?
cd /mnt/dietpi_userdata/node-red
sudo rm -R node_modules
sudo -u nodered npm up --no-audit
That should install and update all packages defined in package.json
and all their dependencies.
Yes, exactly what I just did. :-) Everything in there was installed through node-red, so I deleted the node_modules directory and tried again. No luck:
/mnt/dietpi_userdata/node-red ❯ cat /mnt/dietpi_userdata/node-red/.npm/_logs/2024-06-25T14_22_15_416Z-debug-0.log
0 verbose cli /usr/local/bin/node /usr/local/bin/npm
1 info using npm@10.8.1
2 info using node@v22.3.0
3 silly config load:file:/usr/local/lib/node_modules/npm/npmrc
4 silly config load:file:/mnt/dietpi_userdata/node-red/.npmrc
5 silly config load:file:/usr/local/etc/npmrc
6 verbose title npm i node-red
7 verbose argv "i" "--no-audit" "node-red"
8 verbose logfile logs-max:10 dir:/mnt/dietpi_userdata/node-red/.npm/_logs/2024-06-25T14_22_15_416Z-
9 verbose logfile /mnt/dietpi_userdata/node-red/.npm/_logs/2024-06-25T14_22_15_416Z-debug-0.log
10 silly logfile start cleaning logs, removing 2 files
11 verbose stack TypeError: Class extends value undefined is not a constructor or null
11 verbose stack at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/minipass-collect/index.js:4:23)
11 verbose stack at Module._compile (node:internal/modules/cjs/loader:1460:14)
11 verbose stack at Module._extensions..js (node:internal/modules/cjs/loader:1544:10)
11 verbose stack at Module.load (node:internal/modules/cjs/loader:1275:32)
11 verbose stack at Module._load (node:internal/modules/cjs/loader:1091:12)
11 verbose stack at wrapModuleLoad (node:internal/modules/cjs/loader:212:19)
11 verbose stack at Module.require (node:internal/modules/cjs/loader:1297:12)
11 verbose stack at require (node:internal/modules/helpers:123:16)
11 verbose stack at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/cacache/lib/get.js:3:17)
11 verbose stack at Module._compile (node:internal/modules/cjs/loader:1460:14)
12 error Class extends value undefined is not a constructor or null
13 verbose cwd /mnt/dietpi_userdata/node-red
14 verbose os Linux 6.1.21-v7+
15 verbose node v22.3.0
16 verbose npm v10.8.1
17 verbose exit 1
18 verbose code 1
19 error A complete log of this run can be found in: /mnt/dietpi_userdata/node-red/.npm/_logs/2024-06-25T14_22_15_416Z-debug-0.log
Hmm, last idea is the cache:
sudo rm -R .npm/_cacache
sudo -u nodered npm up --no-audit
EDIT: Actually, it seems to be also possibly that only some older globally installed modules break it:
So a general issue when upgrading from Node v14. In this particular case with minipass-collect
is is just strange, since this is part of the Node.js archive itself, same as npm
. So those 3 should be assured to be compatible with each other. Removing all globally installed modules on Node.js updates is of course not great either.
... looking further at it: I is actually not the globally installed minipass-collect
module, but the one shipped as (nested) dependency of npm
. On Node.js update, we just unpack the new archive onto the old /usr/local
, which means that theoretically /usr/local/lib/node_modules/npm/node_modules
can still have obsolete remains from old (incompatible) npm
versions. So if above does not work either, here another attempt:
sudo rm -R /usr/local/lib/node_modules/{corepack,npm}
dietpi-software reinstall 122
EDIT2: I added the corepack
and npm
removal to our Node.js installer as well now, so you could skip the first command. Whether it solves your particular issue or not, it makes sense in any case: https://github.com/MichaIng/nodejs-linux-installer/commit/0b430e5
So after some searching online I found that this is an error that sometimes occurs when using the n
tool to manage nod versions, which is what I have been doing for years. I deleted the n directory, then removed and reinstalled node-js using the dietpi-software tool.
Then used option 1 from your earlier post (https://github.com/MichaIng/DietPi/issues/7128#issuecomment-2189004611) to install the latest node-red.
Node and node-red are now successfully running again, and node-red is on the latest version. I have not lost any data in node-red, so that's a win. Doing this does seem to have broken my pm2 install though, but I was only using pm2 for a single service, so fixing that should be relatively easy.
EDIT: pm2 started automatically again after a reboot, and my service is back up and running, so all is well.
Happy I got this far and thanks for your help on this!
Ah yeah that makes sense, so the Node version did not match the npm
version. If n
is already installed, we could actually just use it to update Node, instead of running our installer.
However, there were as well issues in the past related to incompatible local Node modules/dependencies. So if a reinstall is done, which includes a Node.js update, it makes sense to reinstall all modules from scratch. I also disabled the local cache now: https://github.com/MichaIng/DietPi/commit/611c047 This increases traffic and processing. However, it makes sense for a reinstall, while for a Node-RED update only, it can be done with much less overhead, according to our docs: https://dietpi.com/docs/software/hardware_projects/#__tabbed_6_5
Additionally, our Node.js installer does not remove the global npm
and corepack
modules, before unpacking the new archive. This alone might have solved your issue already. Of course, it basically replaces the any Node version which may have been installed via n
. I do not remember exactly how it works, but I think it creates symlinks for modules and executables, which are replaced with actual files/dirs when the archive is unpacked.
Hit an error after running
dietpi-software reinstall 122
Muy goal was to upgrade my existing nod-red installation to version 4.0.All was proceeding well until here:
I used the built in bug report function, and as you can see it created a reference code for the issue.
System info:
Linux DietPi 6.1.21-v7+ #1642 SMP Mon Apr 3 17:20:52 BST 2023 armv7l GNU/Linux
sudo -u nodered npm i --no-audit node-red