Run Javascript in the command line without NodeJS, on Mac.

This is a pretty cool hack I just found today on my Mac. So turns out there is a Javascript CMD Line compiler that comes shipped with Mac! Here is how to use it:

First make sure its on your computer by running this:

ls /System/Library/Frameworks/JavaScriptCore.framework/Resources

That should return something like this:

BridgeSupport Info.plist jsc version.plist

Now you just export this to your .bash_profile or .bashrc:

export PATH=$PATH:/System/Library/Framework/JavaScriptCore.framework/Resources

And then for easy use add this to the line under it:

alias js=”jsc”

Now run it on a Javascript file:

js coffee.js

Hope you thought this was cool!

See ya soon!