How to run JavaScript using jsc on OS X?

后端 未结 3 1544
天命终不由人
天命终不由人 2021-01-30 10:46

I got this when I was trying to find some way to run my JavaScript programs through terminal. The run and load command mentioned can execute external J

3条回答
  •  耶瑟儿~
    2021-01-30 11:33

    Complements of this post, JSC lives at

    /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc
    

    and is not in the shell PATH by default. You can fix that with

    ln -s /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc /usr/local/bin
    

    jsc takes filenames as arguments. You could run a file named demo.js with

    jsc demo.js
    

    Note that you'll have to use debug() instead of the conventional console.log() in your script to see any output.

提交回复
热议问题