-
Notifications
You must be signed in to change notification settings - Fork 48
CLJS REPL on Node.js in Cursive
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.
-
Modify
deps.edn
according to the instructions in the README. -
In your project directory, create a sub-directory
dev
. -
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]"
-
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
- Script path:
-
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>
- Project:
-
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))
-
Run ‘nREPL Server’.
-
Run ‘CLJS REPL’.
-
Go to
dev/cljs_repl.clj
and run Tools → REPL → Load File in REPL. On my system, the keyboard shortcut is ⌥⇧L. -
Make sure the ClojureScript REPL has started by evaluating
(js/console.log "Police Squad!")
.