Npm update error "Cannot convert undefined or null to object"

When running "npm update" in my ./.node-red directory I get the error "Cannot convert undefined or null to object". The Idealtree seems to run to completion. The error log looks like this:

0 verbose cli /usr/bin/node /usr/bin/npm
1 info using npm@8.18.0
2 info using node@v16.17.0
3 timing npm:load:whichnode Completed in 1ms
4 timing config:load:defaults Completed in 5ms
5 timing config:load:file:/usr/lib/node_modules/npm/npmrc Completed in 3ms
6 timing config:load:builtin Completed in 3ms
7 timing config:load:cli Completed in 13ms
8 timing config:load:env Completed in 1ms
9 timing config:load:file:/home/pi/.node-red/.npmrc Completed in 1ms
10 timing config:load:project Completed in 6ms
11 timing config:load:file:/home/pi/.npmrc Completed in 3ms
12 timing config:load:user Completed in 4ms
13 timing config:load:file:/usr/etc/npmrc Completed in 0ms
14 timing config:load:global Completed in 2ms
15 timing config:load:validate Completed in 2ms
16 timing config:load:credentials Completed in 3ms
17 timing config:load:setEnvs Completed in 2ms
18 timing config:load Completed in 44ms
19 timing npm:load:configload Completed in 45ms
20 timing npm:load:mkdirpcache Completed in 2ms
21 timing npm:load:mkdirplogs Completed in 2ms
22 verbose title npm update
23 verbose argv "update"
24 timing npm:load:setTitle Completed in 4ms
25 timing config:load:flatten Completed in 11ms
26 timing npm:load:display Completed in 17ms
27 verbose logfile logs-max:10 dir:/home/pi/.npm/_logs
28 verbose logfile /home/pi/.npm/_logs/2022-09-07T09_53_16_849Z-debug-0.log
29 timing npm:load:logFile Completed in 17ms
30 timing npm:load:timers Completed in 1ms
31 timing npm:load:configScope Completed in 0ms
32 timing npm:load Completed in 93ms
33 timing arborist:ctor Completed in 2ms
34 silly logfile start cleaning logs, removing 13 files
35 timing idealTree:init Completed in 73ms
36 timing idealTree:userRequests Completed in 1ms
37 silly idealTree buildDeps
38 silly fetch manifest @clysema/node-red-contrib-ui-week-schedule@~0.1.4
39 silly logfile done cleaning log files
40 timing arborist:ctor Completed in 0ms
41 http fetch GET 200 https://registry.npmjs.org/@clysema%2fnode-red-contrib-ui-week-schedule 2509ms (cache revalidated)42 silly fetch manifest bcryptjs@^2.4.3
43 http fetch GET 200 https://registry.npmjs.org/bcryptjs 77ms (cache updated)
44 silly fetch manifest industrialcomm@~1.1.6
45 http fetch GET 200 https://registry.npmjs.org/industrialcomm 746ms (cache revalidated)
46 silly fetch manifest node-red-admin@^0.2.7
47 http fetch GET 200 https://registry.npmjs.org/node-red-admin 230ms (cache revalidated)
48 silly fetch manifest node-red-contrib-bigssh@^1.2.9
49 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-bigssh 242ms (cache revalidated)
50 silly fetch manifest node-red-contrib-binary@~0.1.3
51 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-binary 249ms (cache revalidated)
52 silly fetch manifest node-red-contrib-bitunloader@^0.3.7
53 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-bitunloader 248ms (cache revalidated)
54 silly fetch manifest node-red-contrib-buffer-array@~1.1.0
55 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-buffer-array 694ms (cache revalidated)
56 silly fetch manifest node-red-contrib-buffer-parser@~3.2.2
57 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-buffer-parser 693ms (cache revalidated)
58 silly fetch manifest node-red-contrib-calc@^1.0.5
59 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-calc 253ms (cache revalidated)
60 silly fetch manifest node-red-contrib-calculate@^0.1.4
61 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-calculate 223ms (cache revalidated)
62 silly fetch manifest node-red-contrib-chronos@^1.18.0
63 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-chronos 673ms (cache revalidated)
64 silly fetch manifest node-red-contrib-collector@0.0.1
65 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-collector 218ms (cache revalidated)
66 silly fetch manifest node-red-contrib-combine@~1.8.1
67 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-combine 233ms (cache revalidated)
68 silly fetch manifest node-red-contrib-configurable-interval@~0.9.1
69 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-configurable-interval 688ms (cache revalidated)
70 silly fetch manifest node-red-contrib-controltimer@~0.1.0
71 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-controltimer 710ms (cache revalidated)
72 silly fetch manifest node-red-contrib-cron-plus@^1.5.7
73 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-cron-plus 783ms (cache revalidated)
74 silly fetch manifest node-red-contrib-dashboard-average-bars@0.0.6
75 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-dashboard-average-bars 276ms (cache revalidated)
76 silly fetch manifest node-red-contrib-dashboard-bar-chart-data@^0.9.8
77 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-dashboard-bar-chart-data 221ms (cache revalidated)
78 silly fetch manifest node-red-contrib-dashboard-sum-bars@0.0.1
79 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-dashboard-sum-bars 243ms (cache revalidated)
80 silly fetch manifest node-red-contrib-data-view@0.0.3
81 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-data-view 694ms (cache revalidated)
82 silly fetch manifest node-red-contrib-date@0.0.2
83 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-date 231ms (cache revalidated)
84 silly fetch manifest node-red-contrib-device-stats@~1.1.2
85 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-device-stats 266ms (cache revalidated)
86 silly fetch manifest node-red-contrib-eztimer@~1.2.7
87 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-eztimer 232ms (cache revalidated)
88 silly fetch manifest node-red-contrib-float@~1.0.3
89 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-float 758ms (cache revalidated)
90 silly fetch manifest node-red-contrib-flow-asserter@~0.4.0
91 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-flow-asserter 257ms (cache revalidated)
92 silly fetch manifest node-red-contrib-flow-manager@~0.7.2
93 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-flow-manager 266ms (cache revalidated)
94 silly fetch manifest node-red-contrib-frequency-meter@0.0.1
95 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-frequency-meter 747ms (cache revalidated)
96 silly fetch manifest node-red-contrib-fs-ops@~1.6.0
97 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-fs-ops 234ms (cache revalidated)
98 silly fetch manifest node-red-contrib-heater-controller@~3.0.2
99 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-heater-controller 245ms (cache revalidated)
100 silly fetch manifest node-red-contrib-interpolate@0.0.4
101 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-interpolate 718ms (cache revalidated)
102 silly fetch manifest node-red-contrib-interval@0.0.1
103 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-interval 713ms (cache revalidated)
104 silly fetch manifest node-red-contrib-interval-length@0.0.6
105 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-interval-length 244ms (cache revalidated)
106 silly fetch manifest node-red-contrib-interval-multiples-timer@~1.0.5
107 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-interval-multiples-timer 271ms (cache revalidated)
108 silly fetch manifest node-red-contrib-jsontimer@~1.2.0
109 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-jsontimer 268ms (cache revalidated)
110 silly fetch manifest node-red-contrib-key-value-store@~0.1.8
111 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-key-value-store 230ms (cache revalidated)
112 silly fetch manifest node-red-contrib-logger@0.0.6
113 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-logger 244ms (cache revalidated)
114 silly fetch manifest node-red-contrib-looptimer2@0.0.2
115 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-looptimer2 747ms (cache revalidated)
116 silly fetch manifest node-red-contrib-m-bus@~2.0.0
117 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-m-bus 260ms (cache revalidated)
118 silly fetch manifest node-red-contrib-modbus@^5.23.1
119 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-modbus 688ms (cache revalidated)
120 silly fetch manifest node-red-contrib-moment@~4.0.0
121 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-moment 706ms (cache revalidated)
122 silly fetch manifest node-red-contrib-msg-speed@~2.1.0
123 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-msg-speed 232ms (cache revalidated)
124 silly fetch manifest node-red-contrib-odoo-xmlrpc-2021@^0.1.0
125 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-odoo-xmlrpc-2021 266ms (cache revalidated)
126 silly fetch manifest node-red-contrib-persist@~1.1.1
127 http fetch GET 200 https://registry.npmjs.org/node-red-contrib-persist 277ms (cache revalidated)
128 silly fetch manifest node-red-contrib-pid@^1.1.7

..........Too long to post all of it, but no errors here

2796 timing idealTree:node_modules/puppeteer-core/node_modules/extract-zip Completed in 6ms
2797 timing idealTree:node_modules/@types/yauzl Completed in 0ms
2798 timing idealTree:node_modules/puppeteer-core/node_modules/get-stream Completed in 0ms
2799 silly placeDep node_modules/puppeteer-core agent-base@6.0.2 OK for: https-proxy-agent@5.0.0 want: 6
2800 timing idealTree:node_modules/puppeteer-core/node_modules/https-proxy-agent Completed in 3ms
2801 timing idealTree:node_modules/puppeteer-core/node_modules/agent-base Completed in 0ms
2802 timing idealTree:node_modules/puppeteer-core/node_modules/ms Completed in 0ms
2803 timing idealTree:node_modules/puppeteer-core/node_modules/progress Completed in 0ms
2804 silly placeDep node_modules/puppeteer-core glob@7.2.3 OK for: rimraf@3.0.2 want: ^7.1.3
2805 timing idealTree:node_modules/puppeteer-core/node_modules/rimraf Completed in 3ms
2806 silly placeDep node_modules/puppeteer-core minimatch@3.1.2 OK for: glob@7.2.3 want: ^3.1.1
2807 silly placeDep ROOT path-is-absolute@1.0.1 OK for: glob@7.2.3 want: ^1.0.0
2808 timing idealTree:node_modules/puppeteer-core/node_modules/glob Completed in 6ms
2809 timing idealTree:node_modules/path-is-absolute Completed in 0ms
2810 silly placeDep node_modules/puppeteer-core brace-expansion@1.1.11 OK for: minimatch@3.1.2 want: ^1.1.7
2811 timing idealTree:node_modules/puppeteer-core/node_modules/minimatch Completed in 2ms
2812 timing idealTree:node_modules/puppeteer-core/node_modules/brace-expansion Completed in 0ms
2813 timing idealTree:node_modules/puppeteer-core/node_modules/ws Completed in 0ms
2814 silly placeDep node_modules/puppeteer ms@2.1.2 OK for: debug@4.3.4 want: 2.1.2
2815 timing idealTree:node_modules/puppeteer/node_modules/debug Completed in 2ms
2816 timing idealTree:node_modules/puppeteer/node_modules/ms Completed in 0ms
2817 silly placeDep ROOT async-limiter@1.0.1 OK for: ws@6.2.2 want: ~1.0.0
2818 timing idealTree:node_modules/puppeteer/node_modules/ws Completed in 4ms
2819 timing idealTree:node_modules/async-limiter Completed in 0ms
2820 timing idealTree:node_modules/request/node_modules/qs Completed in 0ms
2821 silly placeDep node_modules/rimraf minimatch@3.1.2 OK for: glob@7.2.3 want: ^3.1.1
2822 timing idealTree:node_modules/rimraf/node_modules/glob Completed in 3ms
2823 silly placeDep node_modules/rimraf brace-expansion@1.1.11 OK for: minimatch@3.1.2 want: ^1.1.7
2824 timing idealTree:node_modules/rimraf/node_modules/minimatch Completed in 3ms
2825 timing idealTree:node_modules/rimraf/node_modules/brace-expansion Completed in 1ms
2826 silly placeDep node_modules/send/node_modules/debug ms@2.0.0 OK for: debug@2.6.9 want: 2.0.0
2827 timing idealTree:node_modules/send/node_modules/debug Completed in 3ms
2828 timing idealTree:node_modules/send/node_modules/mime Completed in 0ms
2829 timing idealTree:node_modules/serialport/node_modules/@serialport/parser-delimiter Completed in 0ms
2830 timing idealTree:node_modules/serialport/node_modules/@serialport/parser-readline Completed in 0ms
2831 silly placeDep node_modules/serialport ms@2.1.2 OK for: debug@4.3.4 want: 2.1.2
2832 timing idealTree:node_modules/serialport/node_modules/debug Completed in 2ms
2833 timing idealTree:node_modules/serialport/node_modules/ms Completed in 0ms
2834 timing idealTree:node_modules/shortid/node_modules/nanoid Completed in 0ms
2835 silly placeDep node_modules/socket.io-client ms@2.0.0 OK for: debug@3.1.0 want: 2.0.0
2836 timing idealTree:node_modules/socket.io-client/node_modules/debug Completed in 2ms
2837 timing idealTree:node_modules/socket.io-client/node_modules/ms Completed in 0ms
2838 silly placeDep node_modules/socket.io-client isarray@2.0.1 OK for: socket.io-parser@3.3.2 want: 2.0.1
2839 timing idealTree:node_modules/socket.io-client/node_modules/socket.io-parser Completed in 2ms
2840 timing idealTree:node_modules/socket.io-client/node_modules/isarray Completed in 0ms
2841 silly placeDep node_modules/socket.io-parser ms@2.1.2 OK for: debug@4.3.4 want: 2.1.2
2842 timing idealTree:node_modules/socket.io-parser/node_modules/debug Completed in 3ms
2843 timing idealTree:node_modules/socket.io-parser/node_modules/ms Completed in 0ms
2844 silly placeDep node_modules/socket.io ms@2.1.2 OK for: debug@4.3.4 want: 2.1.2
2845 timing idealTree:node_modules/socket.io/node_modules/debug Completed in 2ms
2846 timing idealTree:node_modules/socket.io/node_modules/ms Completed in 0ms
2847 timing idealTree:node_modules/streamroller/node_modules/debug Completed in 0ms
2848 silly placeDep node_modules/streamroller isarray@0.0.1 OK for: readable-stream@1.1.14 want: 0.0.1
2849 silly placeDep node_modules/streamroller string_decoder@0.10.31 OK for: readable-stream@1.1.14 want: ~0.10.x
2850 timing idealTree:node_modules/streamroller/node_modules/readable-stream Completed in 4ms
2851 timing idealTree:node_modules/streamroller/node_modules/isarray Completed in 0ms
2852 timing idealTree:node_modules/streamroller/node_modules/string_decoder Completed in 0ms
2853 timing idealTree:node_modules/tar-stream/node_modules/readable-stream Completed in 0ms
2854 timing idealTree:node_modules/tar/node_modules/safe-buffer Completed in 0ms
2855 timing idealTree:node_modules/tar/node_modules/yallist Completed in 0ms
2856 silly placeDep node_modules/thingzi-logic-timers iconv-lite@0.6.3 OK for: needle@3.1.0 want: ^0.6.3
2857 timing idealTree:node_modules/thingzi-logic-timers/node_modules/needle Completed in 3ms
2858 timing idealTree:node_modules/thingzi-logic-timers/node_modules/iconv-lite Completed in 0ms
2859 timing idealTree:node_modules/url/node_modules/punycode Completed in 1ms
2860 timing idealTree:node_modules/util/node_modules/inherits Completed in 0ms
2861 timing idealTree:node_modules/verror/node_modules/core-util-is Completed in 0ms
2862 silly placeDep node_modules/wrap-ansi is-fullwidth-code-point@3.0.0 OK for: string-width@4.2.3 want: ^3.0.0
2863 timing idealTree:node_modules/wrap-ansi/node_modules/string-width Completed in 2ms
2864 timing idealTree:node_modules/wrap-ansi/node_modules/is-fullwidth-code-point Completed in 0ms
2865 silly placeDep node_modules/wrap-ansi ansi-regex@5.0.1 OK for: strip-ansi@6.0.1 want: ^5.0.1
2866 timing idealTree:node_modules/wrap-ansi/node_modules/strip-ansi Completed in 2ms
2867 timing idealTree:node_modules/wrap-ansi/node_modules/ansi-regex Completed in 0ms
2868 timing idealTree:node_modules/xmlrpc/node_modules/xmlbuilder Completed in 0ms
2869 silly placeDep node_modules/yargs is-fullwidth-code-point@3.0.0 OK for: string-width@4.2.3 want: ^3.0.0
2870 silly placeDep node_modules/yargs strip-ansi@6.0.1 OK for: string-width@4.2.3 want: ^6.0.1
2871 timing idealTree:node_modules/yargs/node_modules/string-width Completed in 9ms
2872 timing idealTree:node_modules/yargs/node_modules/is-fullwidth-code-point Completed in 0ms
2873 silly placeDep node_modules/yargs ansi-regex@5.0.1 OK for: strip-ansi@6.0.1 want: ^5.0.1
2874 timing idealTree:node_modules/yargs/node_modules/strip-ansi Completed in 3ms
2875 timing idealTree:node_modules/yargs/node_modules/ansi-regex Completed in 0ms
2876 timing idealTree:node_modules/send/node_modules/debug/node_modules/ms Completed in 0ms
2877 timing idealTree:buildDeps Completed in 71572ms
2878 timing idealTree:fixDepFlags Completed in 42ms
2879 timing idealTree Completed in 71694ms
2880 timing command:update Completed in 71764ms
2881 verbose stack TypeError: Cannot convert undefined or null to object
2881 verbose stack     at Function.keys (<anonymous>)
2881 verbose stack     at module.exports (/usr/lib/node_modules/npm/node_modules/npm-pick-manifest/lib/index.js:213:22)
2881 verbose stack     at RegistryFetcher.manifest (/usr/lib/node_modules/npm/node_modules/pacote/lib/registry.js:125:22)
2881 verbose stack     at async Arborist.[nodeFromEdge] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1107:19)
2881 verbose stack     at async Arborist.[buildDepStep] (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:976:11)
2881 verbose stack     at async Arborist.buildIdealTree (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:218:7)
2881 verbose stack     at async Promise.all (index 1)
2881 verbose stack     at async Arborist.reify (/usr/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:154:5)
2881 verbose stack     at async Update.exec (/usr/lib/node_modules/npm/lib/commands/update.js:65:5)
2881 verbose stack     at async module.exports (/usr/lib/node_modules/npm/lib/cli.js:78:5)
2882 verbose cwd /home/pi/.node-red
2883 verbose Linux 5.10.103-v7l+
2884 verbose node v16.17.0
2885 verbose npm  v8.18.0
2886 error Cannot convert undefined or null to object
2887 verbose exit 1
2888 timing npm Completed in 72251ms
2889 verbose unfinished npm timer reify 1662544397327
2890 verbose unfinished npm timer reify:loadTrees 1662544397385
2891 verbose code 1
2892 error A complete log of this run can be found in:
2892 error     /home/pi/.npm/_logs/2022-09-07T09_53_16_849Z-debug-0.log

Node-RED version : 3.0.2
Node version v16.17.0
Raspberry pi 4

This happened after upgrading Node-RED and Node.js to the latest version. I had run "npm update" before that without any issue. When I update nodes through the graphical interface, that works fine without any problem. Does anyone have a suggestion on how to get rid of this error?

I fixed the issue by moving my .node-red directory to a safe place, then restarting node-red. Then I copied everything except the node_modules directory and the pakage.json file to the new .node-red directory. After another restart of node-red, it started complaining about all the missing modules. I installed those by hand , using npm. Restarting node-red and running npm update once in a while during this proces. In the end, all was ok and things are working again.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.