Skip to content

Instantly share code, notes, and snippets.

@rubenlozano
Last active July 26, 2021 13:39
Show Gist options
  • Save rubenlozano/4521689 to your computer and use it in GitHub Desktop.
Save rubenlozano/4521689 to your computer and use it in GitHub Desktop.
Running JavaScript in OS X terminal
There is a javascript console, called JSC, in:
/System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Resources/jsc
JSC is not in the shell PATH by default, to fix that:
$ sudo ln /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc /usr/local/bin
Note that you'll have to use debug() instead of the conventional console.log() in your script to see any output.
@Rahizo
Copy link

Rahizo commented Nov 18, 2018

Huh?

@BorisAnthony
Copy link

BorisAnthony commented May 1, 2020

I found it on my system (macOS 10.15.4) here:
/System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Helpers/jsc
(so, "Helpers/" instead of "Resources/")

and the ln command requires the -s option and the symlink name, so:
sudo ln -s /System/Library/Frameworks/JavaScriptCore.framework/Versions/Current/Helpers/jsc /usr/local/bin/jsc

@HFhassan
Copy link

ln: /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc: No such file or directory

getting this error

@due-nguyen
Copy link

JavaScript is not built-in Mac OS by default?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment