CLJS REPL on Node.js in Cursive - nrepl/piggieback GitHub Wiki

This is one way to connect Cursive with a ClojureScript REPL running on Node.js, using tools.deps. If you know a better way, please update this page.

  1. Modify deps.edn according to the instructions in the README.

  2. In your project directory, create a sub-directory dev.

  3. Create a file dev/run-nrepl-server.sh with these contents:

    #!/bin/bash
    
    # Starts an nREPL for your favourite editor or IDE to connect to.
    
    exec clj -R:nrepl -m nrepl.cmdline --middleware "[cider.piggieback/wrap-cljs-repl]"
    
  4. Create a Shell Script run configuration named ‘nREPL Server’ with the following parameters changed from default:

    • Script path: <path to project directory>/dev/run-nrepl-server.sh
    • ☑ Allow parallel run
    • ☐ Activate tool window
  5. Create a Clojure Remote REPL run configuration named ‘CLJS REPL’ with the following parameters changed from default:

    • Connection type: nREPL
    • Connection details: Use port from nREPL file
      • Project: <name of your project>
  6. Create a file dev/cljs_repl.clj with these contents:

    (ns cljs-repl
    "Starts a ClojureScript REPL in a given Clojure nREPL connection.
    
    Usage:
    1. Start run-nrepl-server.sh.
    2. Connect to the resulting nREPL port.
    3. Load this namespace in the resulting REPL."
    (:require [cider.piggieback :as piggieback]
              cljs.repl.node))
    
    (piggieback/cljs-repl (cljs.repl.node/repl-env))
    
    
  7. Run ‘nREPL Server’.

  8. Run ‘CLJS REPL’.

  9. Go to dev/cljs_repl.clj and run Tools → REPL → Load File in REPL. On my system, the keyboard shortcut is ⌥⇧L.

  10. Make sure the ClojureScript REPL has started by evaluating (js/console.log "Police Squad!").