CONTEXT
Not infrequently in the forum the question is asked "What version of Node-red, node.js and node-red do you have?"
node -v and npm -v happily report the version and exit
pi@GlassPi:~ $ node -v
v18.20.2
pi@GlassPi:~ $ npm -v
10.5.0
But Node-red attempts to start the program and (if it's already running) errors.
There is more useful info than merely the Node-red version in the output though:
pi@GlassPi:~ $ node-red -v
11 Jun 17:38:38 - [info]
Welcome to Node-RED
===================
11 Jun 17:38:38 - [info] Node-RED version: v3.1.9
11 Jun 17:38:38 - [info] Node.js version: v18.20.2
11 Jun 17:38:38 - [info] Linux 6.6.28+rpt-rpi-v8 arm64 LE
11 Jun 17:38:39 - [info] Loading palette nodes
11 Jun 17:38:41 - [info] Dashboard version 3.6.5 started at /ui
11 Jun 17:38:42 - [info] Settings file : /home/pi/.node-red/settings.js
11 Jun 17:38:42 - [info] Context store : 'default' [module=memory]
11 Jun 17:38:42 - [info] User directory : /home/pi/.node-red
11 Jun 17:38:42 - [warn] Projects disabled : editorTheme.projects.enabled=false
11 Jun 17:38:42 - [info] Flows file : /home/pi/.node-red/flows.json
11 Jun 17:38:42 - [error] Unable to listen on http://127.0.0.1:1880/
11 Jun 17:38:42 - [error] Error: port in use
PROPOSAL
Allow a command line flag -v & --version which outputs the following but does not attempt to start the editor.
(The colours were inserted by the forum)
Node-RED version: v3.1.9
Settings file : /home/pi/.node-red/settings.js
Context store : 'default' [module=memory]
User directory : /home/pi/.node-red
Projects disabled : editorTheme.projects.enabled=false
Flows file : /home/pi/.node-red/flows.json