How to get installed version of NR?

I was using the following to get the latest version of NR available, and it still works...

npm search node-red | grep Low-code | cut -d '|' -f4-5

And I was using the following to get the installed version, but this seems to be broken at the moment...

npm ls -g --depth=0 | grep node-red | cut  -d '@' -f 2

Any suggestions as to how to find the installed version of NR? This is where I really wish the 'node-red-project' line showed the correct installed version. But that is a question we discussed a long time ago. :slight_smile:

npm list | grep node-red
node-red-project@0.0.1 /home/pi/.node-red
โ”œโ”€โ”€ node-red-contrib-bme280@1.0.0
โ”œโ”€โ”€ node-red-contrib-counter@0.1.6
โ”œโ”€โ”€ node-red-contrib-cron-plus@1.5.6
โ”œโ”€โ”€ node-red-contrib-fs-ops@1.6.0
โ”œโ”€โ”€ node-red-contrib-linux-network-stats@0.2.5
โ”œโ”€โ”€ node-red-contrib-loop-processing@0.5.1
โ”œโ”€โ”€ node-red-contrib-md5@1.0.4
โ”œโ”€โ”€ node-red-contrib-os@0.2.1
โ”œโ”€โ”€ node-red-contrib-play-audio@2.5.0
โ”œโ”€โ”€ node-red-contrib-ring-buffer@0.10.0
โ”œโ”€โ”€ node-red-contrib-simple-gate@0.5.2
โ”œโ”€โ”€ node-red-contrib-traffic@0.2.1
โ”œโ”€โ”€ node-red-contrib-ui-led@0.4.11
โ”œโ”€โ”€ node-red-dashboard@3.1.5
โ”œโ”€โ”€ node-red-node-mysql@1.0.0
โ”œโ”€โ”€ node-red-node-pi-gpio@2.0.1
โ”œโ”€โ”€ node-red-node-pi-gpiod@0.4.0
โ”œโ”€โ”€ node-red-node-ping@0.3.1
โ”œโ”€โ”€ node-red-node-random@0.4.0
โ”œโ”€โ”€ node-red-node-serialport@0.15.0
โ”œโ”€โ”€ node-red-node-smooth@0.1.2
โ”œโ”€โ”€ node-red-node-ui-list@0.3.6
โ”œโ”€โ”€ node-red-node-ui-table@0.3.12

And of course a few other past variants seem to be failing as well...

$ npm list -g node-red
/usr/local/lib
โ””โ”€โ”€ (empty)

$ npm list node-red
node-red-project@0.0.1 /home/pi/.node-red
โ””โ”€โ”€ (empty)

My way of updating NR is this command:

bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)

@Trying_to_learn, Sorry, No, NOT updating, that is NOT the question... need installed version.

I checked an older install, and the older method works on older installations...
# npm list -g node-red
/usr/lib
โ””โ”€โ”€ node-red@2.1.4

So something changed with how deployment is done, which apparently breaks the old method of determining the INSTALLED version.

You cannot have good auditing or QC or QA controls unless you can properly document the existing environment. This should be a standard feature any solution. A point I have made before, that reliance on 3rd party tool, i.e. npm, to find the installed version of an solution is not a good idea per se. Again, I suggest that $ node-red -v would be a good idea.

Speaking of where the version information is displayed, how does the flow wire editor, know what version is installed? Is it just a static string? Or dynamic value derived in some way? Clearly the editor shows the version installed, right?

If you want to get the installed version....

Just to the right of the DEPLOY button is a burger button/menu.

Click it and you get the drop down.

The version is at the bottom.

1 Like

That is useless... for automation or any realistic methodology of environment documentation. You can't go every device and manual look up the version, are you really suggesting that is a good method? You can't be.

O.k.a.y... above my knowledge than. Sorry.

Actually this an old issue... that should be address by development effort. You can only suggest what you can know of, of course. I found a work-around, that is now broken.

npm -g info node-red version

โ†‘ assumes node-red is installed globally

To find the available version you can use list or info. Not the installed version.

On a 2.1.4 install the command returns...
2.2.2

On a 2.2.2 install the command returns...
$ npm list -g node-red
/usr/local/lib
โ””โ”€โ”€ (empty)

$ npm list node-red
node-red-project@0.0.1 /home/pi/.node-red
โ””โ”€โ”€ (empty)

So, that specific command does not show the installed version at all. Where as my old command on older installations worked...

On older 2.1.4...
# npm ls -g --depth=0 | grep node-red | cut -d '@' -f 2
2.1.4

On 2.2.2...
# npm ls -g --depth=0 | grep node-red | cut -d '@' -f 2
(Nothing Results)

$ npm ls --depth=0 | grep node-red
node-red-project@0.0.1 /home/pi/.node-red
โ”œโ”€โ”€ node-red-contrib-bme280@1.0.0
โ”œโ”€โ”€ node-red-contrib-counter@0.1.6
โ”œโ”€โ”€ node-red-contrib-cron-plus@1.5.6
โ”œโ”€โ”€ node-red-contrib-fs-ops@1.6.0
โ”œโ”€โ”€ node-red-contrib-linux-network-stats@0.2.5
โ”œโ”€โ”€ node-red-contrib-loop-processing@0.5.1
โ”œโ”€โ”€ node-red-contrib-md5@1.0.4
โ”œโ”€โ”€ node-red-contrib-os@0.2.1
โ”œโ”€โ”€ node-red-contrib-play-audio@2.5.0
โ”œโ”€โ”€ node-red-contrib-ring-buffer@0.10.0
โ”œโ”€โ”€ node-red-contrib-simple-gate@0.5.2
โ”œโ”€โ”€ node-red-contrib-traffic@0.2.1
โ”œโ”€โ”€ node-red-contrib-ui-led@0.4.11
โ”œโ”€โ”€ node-red-dashboard@3.1.5
โ”œโ”€โ”€ node-red-node-mysql@1.0.0
โ”œโ”€โ”€ node-red-node-pi-gpio@2.0.1
โ”œโ”€โ”€ node-red-node-pi-gpiod@0.4.0
โ”œโ”€โ”€ node-red-node-ping@0.3.1
โ”œโ”€โ”€ node-red-node-random@0.4.0
โ”œโ”€โ”€ node-red-node-serialport@0.15.0
โ”œโ”€โ”€ node-red-node-smooth@0.1.2
โ”œโ”€โ”€ node-red-node-ui-list@0.3.6
โ”œโ”€โ”€ node-red-node-ui-table@0.3.12

(Of course none of the above are 2.2.2)

This is either because something changed with how deployment is done, presented, or something has changed with how npm or such works, or whatever the case. It does not change the fact or issue that NR should have some way via CLI or node, to report its current installed version information.

So, my questions stands... how does the wire editor know what version is installed, is it a static value? Or dynamic determined? Is there some way to present that information other than using npm? Or if npm is the only option? How can one find such that is not a human action dependent sequence? Something via CLI, that automation can invoke is what is needed. If there is a CLI method that works, like before, I can do the rest, via Ansible or whatever.

via CLI

pi@pi:~ $ node-red admin info node-red
Module: node-red
Version: 2.2.0

This is one of many reasons that I never install Node-RED globally but instead put it in its own folder with the userDir as a sub-folder. With that approach, you can simply query the package.json file of the parent folder when in Node-RED.

I expect that the Node-RED editor is passed the data from one of the node.js modules which of course are running in the correct context to be able to query its own package.json file.

node -p "require('/usr/lib/node_modules/node-red/package.json').version"

Which is OK but not resilient since it may not be in that location at all :slight_smile: It certainly isn't when running on Windows.

Of course but as node-red could be installed anywhere this solution expects the user to specify the instance path.

@TotallyInformation I use the standard script. So not sure why the old method worked since NR should be local under /home/pi scope.

@Andrei, Yahoo!

NOTE: @Andrei solution will only work if node-red is running.

The one i offered above doesnt need node-red running.

1 Like

@TotallyInformation Good point... I can't say that I have ever run NR on Windows.

@Steve-Mcl , I can design the automation, i.e. Ansible, to try the applicable method, if NR is not active, or is.

If you have access to a custom node, you can get the version using RED.version()

The real point is that a global install of something using npm could end up in various different places.

I see one odd issue... for some reason one of my test 2.2.2 instances, the method is not working.

# node-red admin info node-red
Failed to connect to http://localhost:1880

Odd, localhost is resolving (local) to 127.0.0.1 and pingable. Something is tripping something up, this is going to be interesting to track down. A raw download via curl, connects and I see the html.

1 Like

What exactly does npm list -g node-red return on your 2.1.4 install?

What version of npm/node.js are using using in those two installs? Did you set them up in the same way?

We haven't changed where Node-RED gets installed. But for some reason your 2.2.2 install using /usr/local/lib for its global path, and I would guess your 2.1.4 install will report /usr/lib.