I have created a ClojureScript project using:
lein new re-frame my-project
I've then opened it in IntelliJ using Cursive. In the terminal after typing lein dev
, it prompts me with the message:
shadow-cljs - HTTP server available at http://localhost:8280
shadow-cljs - server version: 2.8.52 running at http://localhost:9630
shadow-cljs - nREPL server started on port 8777
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (203 files, 1 compiled, 0 warnings, 3.65s)
I can open the server using the link which directs me to a REPL, but not the nREPL connected to the browser. Following their documentation I type shadow-cljs clj-repl
in to another terminal, which opens a REPL but not one that is connected to my browser or project. If I type (js/alert "hi m8")
in to the REPL it responds:
Syntax error compiling at (REPL:2:1).
No such namespace: js
My question is, is how do I use the nREPL it says has started and preferably how do I access it in the integrated REPL in IntelliJ?
Have got it working as below, but I'd like to get it working here in Cursive / IntelliJ:
The nREPL connection will always start out in Clojure mode. You can switch it to use CLJS by calling (shadow.cljs.devtools.api/repl :app)
and return to Clojure mode via :cljs/quit
.
You should however be connecting to a "Clojure REPL" -> "Remote" and then "localhost" with port 8777
. This is configured as the default in the re-frame
template via shadow-cljs.edn
:nrepl {:port 8777}
.
The screenshot you posted looks like you connected to the random port lein
created. This will also work but requires additional configuration for the nREPL middleware.