简体   繁体   中英

Launch cljs nREPL connected to lein project template

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?

Thanks.

Update

Have got it working as below but if anyone knows how to get it working here in Cursive / IntelliJ:

在此处输入图片说明

That would be super.

I figured it. You have to use shadow-cljs cljs-repl app in another terminal.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM