Skip to main content

We had a need to do an inventory of which of our Macs has Node.js installed and to display the Node.js version. I wanted to share this in case it's helpful for anyone else. Basically it checks to see if /usr/local/bin/node is present and if so it runs a command to display the version number. Here's the script:



#!/bin/bash

# Tests to see if Node.js is installed. If it is, it outputs the version number. If it’s not, it states that Node.js is not installed.

if f -f "/usr/local/bin/node" ]
then
echo "<result>`node -v`</result>"
else
echo "<result>Node.js is not installed</result>"
fi

Thanks @john.sherrod , very useful!


Hi @john_sherrod , I have tried this script manually and it works, of course. But having added it as a JAMF EA, it returns zero results in JAMF Pro. I tried the EA as an 'integer' and as a 'string'. I know we have users with Node.js installed, just wondering how to config the EA if I'm doing something wrong?


Hi @john_sherrod , I have tried this script manually and it works, of course. But having added it as a JAMF EA, it returns zero results in JAMF Pro. I tried the EA as an 'integer' and as a 'string'. I know we have users with Node.js installed, just wondering how to config the EA if I'm doing something wrong?


Hmmm… I have mine said to “string” since it actually puts a v before the version number. Just verified that it’s still working in my Jamf Pro instance. You’ve got it copied in exactly as I have it above into the EA, right? Just making sure we’ve got the <result></result> in there since Jamf needs that for the EA to work.


How peculiar. I copied your code above once more and pasted it over the pre-pasted code in JAMF Settings and saw no change, ensured the type was set to String, and identified 'Which Node installed?" as a new display item. I now see either "Node.js is not installed" or blank (nothing) for the inventory. So, it's working partway now, which is excellent, thank you.


How peculiar. I copied your code above once more and pasted it over the pre-pasted code in JAMF Settings and saw no change, ensured the type was set to String, and identified 'Which Node installed?" as a new display item. I now see either "Node.js is not installed" or blank (nothing) for the inventory. So, it's working partway now, which is excellent, thank you.


Gotta love how if one tiny little thing is off it completely refuses to understand what you’re trying to do. 😂