Extension Attribute for Determining if Node.js is Installed and Displaying the Version if So

john_sherrod
Contributor II

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 "/usr/local/bin/node" ]
then
    echo "<result>`node -v`</result>"
else
    echo "<result>Node.js is not installed</result>"
fi
2 REPLIES 2

julienvs
New Contributor III

Thanks @john.sherrod , very useful!

thellum
New Contributor III

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?