Skip to content

Instantly share code, notes, and snippets.

@alejandrosuarez
Forked from rosswd/js-cmd-line.md
Created May 11, 2023 13:54
Show Gist options
  • Save alejandrosuarez/cd1883bca567a8825e7553c1138708b5 to your computer and use it in GitHub Desktop.
Save alejandrosuarez/cd1883bca567a8825e7553c1138708b5 to your computer and use it in GitHub Desktop.

Revisions

  1. @rosswd rosswd revised this gist May 10, 2019. 1 changed file with 9 additions and 6 deletions.
    15 changes: 9 additions & 6 deletions js-cmd-line.md
    Original file line number Diff line number Diff line change
    @@ -7,11 +7,12 @@ I get quite frustrated running JS by pasting into Chrome/FF and sometimes I like

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

    ### Bring up the REPL
    ### 1. Use the jsc alias as a REPL

    `jsc`

    ### Run a script
    ### 2. Run a script using the jsc alias
    Create a file and save it. Change to the saved directory and execute the file:

    `jsc hello.js`

    @@ -21,11 +22,12 @@ I get quite frustrated running JS by pasting into Chrome/FF and sometimes I like

    `brew update && brew install node`

    ### Bring up the REPL:
    ### 1. Bring up the REPL:

    `node`

    ### Run a script:
    ### 2. Run a script:
    Create a file and save it. Change to the saved directory and execute the file:

    `node hello.js`

    @@ -35,10 +37,11 @@ I get quite frustrated running JS by pasting into Chrome/FF and sometimes I like

    `brew update && brew install phantomjs`

    Bring up the REPL:
    ### 1. Bring up the REPL:

    `phantomjs`

    Run a script:
    ### 2. Run a script:
    Create a file and save it. Change to the saved directory and execute the file:

    `phantomjs hello.js`
  2. @rosswd rosswd revised this gist Oct 24, 2014. 1 changed file with 14 additions and 5 deletions.
    19 changes: 14 additions & 5 deletions js-cmd-line.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    # Running JavaScript from the command line
    I get quite frustrated running JS by pasting into Chrome/FF and sometimes I like to keep everything local. These are some notes on using Apple's built in intrerpreter, node or phantom.

    ## Using Apple's built in interpreter

    @@ -16,20 +17,28 @@

    ## Using Node.js

    ### Install Node using homebrew
    ### Install Node using homebrew

    `brew update && brew install node`

    ### Bring up the REPL: `node`
    ### Bring up the REPL:

    ### Run a script: `node hello.js`
    `node`

    ### Run a script:

    `node hello.js`

    ## Using PhantomJS

    ### Install phantomjs using homebrew

    `brew update && brew install phantomjs`

    Bring up the REPL: `phantomjs`
    Bring up the REPL:

    `phantomjs`

    Run a script:

    Run a script: `phantomjs hello.js`
    `phantomjs hello.js`
  3. @rosswd rosswd created this gist Sep 27, 2014.
    35 changes: 35 additions & 0 deletions js-cmd-line.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    # Running JavaScript from the command line

    ## Using Apple's built in interpreter

    ### Create a symlink by putting `jsc` into `/usr/bin`

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

    ### Bring up the REPL

    `jsc`

    ### Run a script

    `jsc hello.js`

    ## Using Node.js

    ### Install Node using homebrew

    `brew update && brew install node`

    ### Bring up the REPL: `node`

    ### Run a script: `node hello.js`

    ## Using PhantomJS

    ### Install phantomjs using homebrew

    `brew update && brew install phantomjs`

    Bring up the REPL: `phantomjs`

    Run a script: `phantomjs hello.js`