Well, that odd npm issue is back! I just tried to mass load modules via the npm cli via the script I wrote, that has been working fine for a while, until that it. On a refresh NR install, after removing NR, node.js, and npm in previous effort, I run my script and npm reports no errors. but the dashboard is missing. Yes, I restarted NR after the npm install attempt, and here is where it gets interesting... the palette manager shows it is not installed, but when I try to install it, NR editor states it already installed. When I look at the log, it tried to install the first time, but if failed, log excert below.
TypeError: Cannot read property 'config' of null
at addWidget (/home/pi/.node-red/node_modules/node-red-dashboard/index.js:72:39)
at Object.addWidget (/home/pi/.node-red/node_modules/node-red-dashboard/index.js:136:48)
at new TableNode (/home/pi/.node-red/node_modules/node-red-node-ui-table/node.js:86:27)
at Object.createNode (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/util.js:493:31)
at Flow.start (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js:193:48)
at start (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/index.js:345:33)
at tryCatchReject (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:845:30)
at runContinuation1 (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:804:4)
at Fulfilled.when (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:592:4)
at Pending.run (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:483:13)
TypeError: Cannot read property 'config' of null
at addWidget (/home/pi/.node-red/node_modules/node-red-dashboard/index.js:72:39)
at Object.addWidget (/home/pi/.node-red/node_modules/node-red-dashboard/index.js:136:48)
at new TableNode (/home/pi/.node-red/node_modules/node-red-node-ui-table/node.js:86:27)
at Object.createNode (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/util.js:493:31)
at Flow.start (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js:193:48)
at start (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/index.js:345:33)
at tryCatchReject (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:845:30)
at runContinuation1 (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:804:4)
at Fulfilled.when (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:592:4)
at Pending.run (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:483:13)
TypeError: Cannot read property 'config' of null
at addWidget (/home/pi/.node-red/node_modules/node-red-dashboard/index.js:72:39)
at Object.addWidget (/home/pi/.node-red/node_modules/node-red-dashboard/index.js:136:48)
at new TableNode (/home/pi/.node-red/node_modules/node-red-node-ui-table/node.js:86:27)
at Object.createNode (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/util.js:493:31)
at Flow.start (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js:193:48)
at start (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/index.js:345:33)
at tryCatchReject (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:845:30)
at runContinuation1 (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:804:4)
at Fulfilled.when (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:592:4)
at Pending.run (/usr/lib/node_modules/node-red/node_modules/when/lib/makePromise.js:483:13)
Manual installation reports on errors...
$ npm install node-red-dashboard
npm WARN node-red-project@0.0.1 No repository field.
npm WARN node-red-project@0.0.1 No license field.
+ node-red-dashboard@2.23.0
updated 1 package and audited 333 packages in 8.414s
5 packages are looking for funding
run `npm fund` for details
found 4 vulnerabilities (3 low, 1 high)
run `npm audit fix` to fix them, or `npm audit` for details
$ sudo systemctl restart nodered
But the same error messages result in the log as noted above.
I had to do a rebuild on npm, then an explicit uninstall of the dashboard, then an install of the dashboard, that finally cleared up the issue. I am doing some more testing but this is what I know so far...
NPM can handle a series of installs, one package per install, too fast. I had batch file that seemed to bury NPM such that it did not consistently actually complete installs. So...
But after doing this for a few days, on remotely deployed devices, yesterday it failed. This was on a Pi device where I had explicitly removed NR, node.js, and npm ealier that day, then installed the same, without apparent issue. Well, maybe not. of the 15 or so packages about 10 showed installed, include dashboard, but as I note above, dashboard was NOT really installed correctly.
So now I am testing against npm again, trying to narrow down this why it seems to be unstable or inconsistent. If you do an install there, and install here, one off type of thing it seems to work, but any time you give it any serious tasking, weird odd stuff seems to result at times.
There were no other errors or exceptions in the log, just the fact that the dashboard was failing to load.
That is just it... there was no errors, no warnings, other than what is show above, from NPM. I did include a print screen of everything NPM showed. The only reference to any problem was in the NR log. That the dashboard failed to load on NR restart. If the npm results had shown any thing I would have commented on that as well.
Yes, I had about 15 on the one liner, and only about 10 or so where actually installed correctly. No errors, just after I restarted NR, and checked the installed list in the palette, noticed the issue. Then checking npm (va list) saw that it was true, missing packages. Moreover, dashboard was listed as installed, but as you have seen above, it was not complete. I tried to run NPM install of dashboard again, it installed with no errors reported, but again as before after restart of NR, errors in the NR log, as exhibited above.
If you could find a repeatable example of failure that would be good. Possibly there is a bug in npm to do with working out all the required dependencies when multiple nodes are installed at once.
One of the problems with demonstrating a repeatable npm issue is that what it does in response to a command depends on what is currently installed, what is in package.json and what is in package-lock.json, all of which will change every time anything is installed.
I realized this morning, that is likely why I did not see failures sooner with my script, because all of the installs via my script where to fresh new build images, from OS on up, at part of my validation testing.
When I hit this latest issue, it was a system where I had removed node.js, NR, and npm. Then reinstalled each via the official script. However, I did not also remove the nodule_modules directory or the package*.json files under the hidden NR directory, an oversight on my part at the time, this may have been a factor.
As this is a Pi, you may also want to check the state of your SD-Card. Also, it would be worth checking whether the "failed" installs have had their node_modules folder created or not - so maybe they are installed but not discovered or partly installed.
For myself, I typically only do an npm update rather than an install but I always first check with npm outdated in case something has has a major update in which case, I'll usually do npm install modulename@latest for that. If you have a major node.js version change, that often needs a reinstall of any module with a binary component and I'll often just delete the whole node_modules folder and then just do npm install which reinstalls everything listed in the package.json.
I realise though that your needs are a bit different here, just explaining my usual workflow.
No, this great information, I have been doing fresh installs and usually will for the remote headless Pi devices. So doing install in my script to me makes sense, since I have an empty clean slate, if you will. Moreover, on an existing system, what you suggest make perfect sense. Being new to node.js and npm, learning more every time I work with it... not to say, reading this forum almost every day now.
npm install won't do anything unless you have something in package*.json. Perhaps, though, you are setting up a system which is seeded with an existing .node-red folder and flows, in which case that is indeed the way to install all required nodejs modules.
Usually it is to a system that has had no previous installs, in that npm has only what it has after the official NR script runs. When this issue happened this was also the case, because I had explicitly removed npm prior to the NR install script run.
If you have seeded package.json then npm install with no parameters will install the latest versions of everything, compatible with the settings in package.json. If you also seed package-lock.json then it will install exactly the versions of everything as you had in the original.
FYI... had dashboard fail to load again. I took a working NR instance, deleted all flows via UI, but one empty flow tab. Then imported a flow file that had about 15 separate flows tabs, they seemed to load fine. Then I stopped and started NR, and on restart, the following errors, over and over...
TypeError: Cannot read property 'config' of null
at addWidget (/home/pi/.node-red/node_modules/node-red-dashboard/index.js:72:39)
at Object.addWidget (/home/pi/.node-red/node_modules/node-red-dashboard/index.js:136:48)
at new TableNode (/home/pi/.node-red/node_modules/node-red-node-ui-table/node.js:57:27)
at Object.createNode (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/util.js:493:31)
at Flow.start (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js:193:48)
at start (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/index.js:345:33)
at /usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/index.js:212:21
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
TypeError: Cannot read property 'config' of null
at addWidget (/home/pi/.node-red/node_modules/node-red-dashboard/index.js:72:39)
at Object.addWidget (/home/pi/.node-red/node_modules/node-red-dashboard/index.js:136:48)
at new TableNode (/home/pi/.node-red/node_modules/node-red-node-ui-table/node.js:57:27)
at Object.createNode (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/util.js:493:31)
at Flow.start (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/Flow.js:193:48)
at start (/usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/index.js:345:33)
at /usr/lib/node_modules/node-red/node_modules/@node-red/runtime/lib/nodes/flows/index.js:212:21
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
The only way I know to fix this, is to completely uninstall NR and Node.js and reinstall same. Then install via package.json the various modules. Finally load the flows file again. Would really like to know why this keeps happening, this is the 3rd or 4th time I get this specific error with dashboard.
Before anyone asks... brand new SSD card, have loaded Rpi OS twice on it, during various testing. It has never had a validation check triggered on reboot.