Anlaysing NodeRED memory - problem "Referenceerror: process is not defined"

Hey there,

I am using NodeRED 2.2.0 with nodeJS 16.3 on 2 machines using windows 10. On both machines I like to analyze the memory consumption, since I sometimes see a heap error like this:

Since there is a pretty good hint in the FAQ to this, I generated the following Flow:

[{"id":"da3d35e1314f395a","type":"inject","z":"ec5785f02d0d6ea6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":260,"y":480,"wires":[["1b4aac38a3d0cd92"]]},{"id":"1b4aac38a3d0cd92","type":"function","z":"ec5785f02d0d6ea6","name":"GetMem","func":"\nlet mem = process.memoryUsage()\nconst formatMem = (m) => (m / 1048576).toFixed(2)\n\nmsg.topic = 'Memory Use (MB)'\nmsg.payload = {\n    Residentset: formatMem(mem.rss),\n    HeapUsed: formatMem(mem.heapUsed),\n    HeapTotal: formatMem(mem.heapTotal),\n    'External C++': formatMem(mem.external),\n    Unit:\"MB\"\n}\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[{"var":"process","module":"process"}],"x":400,"y":480,"wires":[["24ec3a426815da70"]]},{"id":"24ec3a426815da70","type":"debug","z":"ec5785f02d0d6ea6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":550,"y":480,"wires":[]}]

On my first machine, it runs fine. On the 2nd machine - with NodeRED I get the following error:

, although the basic function like described in the FAQ (also using process) at the first start of NodeRED runs fine.

I wonder, why on one machine it works and on the other not.

Any tips are most welcome.

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