Running "npm install" from Jamf

b_rant
New Contributor II

I am attempting to run npm installs via a script from self service. However there are nothing but errors, these installs work fine if run from terminal.

Have tried the following:

su -l $currentuser -c npm install aws-cdk-lib
su $currentuser -c npm install aws-cdk-lib
sudo -H -iu $currentuser npm install aws-cdk-lib

These all return an error of "Script result: zsh:1: command not found: npm"

Picking apart a brew install script I have, I noticed it referenced an exec file for the "brew" portion of the install command located in the /opt/homebrew/bin/brew folder. There is no such npm folder, so I had to improvise and found a similarly named exec file.

Trying to replicate this I created the following:

npm=/Users/${currentuser}/.nvm/versions/node/v21.1.0/lib/node_modules/npm/bin/npm
cd ~
sudo -H -iu ${currentuser} ${npm} install aws-cdk-lib

This returns the most educated error of "Script result: Could not determine Node.js install directory"


I feel like I'm getting closer, but am hitting a wall with my scripting knowledge and these package managers.

Any information here would be appreciated! Thank you!

0 REPLIES 0