Automator – Fixing Node Command Errors in AppleScript

automator

I am trying to run an AppleScript that runs a node command like I would run it in terminal and appear to have the right start with the code, but I'm getting hung up on Automator not recognizing the node command sh: node: command not found. Can anyone point me to the reason why automator can't locate node (node command as in Node.js. Node.js is installed on my machine)?

Here is my AppleScript:

do shell script "cd /Users/user/Desktop/Projects/node/cli && node app.js DesktopUSA"

Best Answer

The PATH variable for your AppleScript doesn't contain /usr/local/bin! You can check this with do shell script "env >> $HOME/Desktop/env.txt".

So either configure an additional path or use the full path to node:

do shell script "cd /Users/user/Desktop/Projects/node/cli && /usr/local/bin/node app.js DesktopUSA"