Skip to main content
Question

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


john_sherrod
Forum|alt.badge.img+17

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

5 replies

Forum|alt.badge.img+10
  • Contributor
  • 26 replies
  • April 18, 2020

Thanks @john.sherrod , very useful!


thellum
Forum|alt.badge.img+4
  • Contributor
  • 12 replies
  • June 6, 2025

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?


john_sherrod
Forum|alt.badge.img+17
  • Author
  • Valued Contributor
  • 104 replies
  • June 9, 2025
thellum wrote:

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.


thellum
Forum|alt.badge.img+4
  • Contributor
  • 12 replies
  • June 9, 2025

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.


john_sherrod
Forum|alt.badge.img+17
  • Author
  • Valued Contributor
  • 104 replies
  • June 9, 2025
thellum wrote:

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. 😂


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings