clojureclojurescriptread-eval-print-loopcidershadow-cljs

Why I can start CIDER's Clojure REPL without a project (no error message) but starting CIDER's clojureScript REPL without a project returns an error?


I have been using with some success the stack of Clojure, ClojureScript, lein, shadow-cljs, Emacs, and CIDER.

Usually, inside a project and for ClojureScript projects, I do: cider-jack-in-cljs, I choose shadow-cljs, then shadow for REPL type, and app for build option.

It works (mostly). Now, I tried the same approach but without a project.

Instead of normally working, I received the following error message:

error in process filter: ClojureScript is not available. See https://docs.cider.mx/cider/basics/clojurescript for details

Still, the REPL is running, but it seems to be only Clojure, not clojureScript - I can do math but no interaction with the browser:

user> (+ 1 2 3)
6

user> (js/alert "test")
Syntax error compiling at (*cider-repl ~:localhost:53866(clj)*:49:7).
No such namespace: js

I tried reading the mentioned link. But it only gives general information. It does not seem to answer the problem in case:

Why I can't start CIDER clojureScript REPL without a project?

Obs.: If I try the same thing with cider-jack-in-clj (which means using Clojure and not ClojureScript) the REPL starts (as user) and there is no error message!


Solution

  • I had a similar problem. I was trying to get emacs org babel to execute clojurescript (NOT clojure) to execute. I read the docs and the error message and tried to add a deps.edn file with clojurescript as dependency:

    {:deps {org.clojure/clojurescript {:mvn/version "1.11.4"}}}
    

    I tried cider-jack-in-cljs again with node as repl type and it worked.

    #+begin_src clojurescript
      (js/Date.)
    #+end_src
    
    #+RESULTS:
    : #inst "2022-10-12T08:45:52.091-00:00"
    

    EDIT:

    Alternatively, add the dependency in emacs directly:

    (add-to-list 'cider-jack-in-cljs-dependencies '("org.clojure/clojurescript" "1.11.4"))