So, I searched and searched. There are many existing blog posts on this topic already. It basically consists of two steps:
- Node.js: Node.js is a event-based JS platform based on the V8 JS engine, see my previous post on how to set it up
- Mozilla JS engines: installation guide to build/install SpiderMonkey, Rhino, TraceMonkey on Mac
- For other JS engines, do a Web search for installation instructions
For command setup to use Node.js, see this github snippet by beastaugh, it basically creates a script that executes another script given the file path.