Hi! I'm setting up a project with shadow-cljs, I'm having trouble eval-ing from Conjure I'm connecting to the shadow-cljs nREPL server, but when I try to eval the ns form I get:
; (err) Syntax error macroexpanding clojure.core/ns at (chrome_tabs_monitor.cljs:3:1).
; (err) ((:require ["fs" :as fs])) - failed: Extra input spec: :clojure.core.specs.alpha/ns-form
(ns foo.bar
(:require ["fs" :as fs]))the default REPL you connect to is a CLJ REPL, you swtich it to CLJS first. for example via (shadow.cljs.devtools.api/node-repl)
got it I think
right now i'm launching shadow-cljs cljs-repl script
what should i do instead?
or you mean i call that from inside the clj repl?
as I said. shadow-cljs cljs-repl script will try to connect you to a process running the script that is created by that build
so you can run node main.js to create that node process
OR, instead you run shadow-cljs node-repl which manages the node process for you
i launched shadow-cljs node-repl script shouldn't that work?
OR you eval (shadow.cljs.devtools.api/node-repl) in the CLJ REPL if you already have that connected
I cannot tell you how the conjure side of things works though
yes I got the same result, i'm getting an error in a loop about a missing module but that is probably just a missing dep
I've started both node-repl and a watch process, The REPL's prompt is`cljs.user` is that expected for a node REPL?
I still get the no JS runtime error, I do have the node-repl and watch script running, and I connected to the REPL using Conjure's dedicated command for shadow-cljs
; --------------------------------------------------------------------------------
; localhost:55038 (connected): /Users/andrei/dev/shadow-cljs-node/.shadow-cljs/nrepl.port
; --------------------------------------------------------------------------------
; Assumed session: Shih Tzu (Unknown )
; --------------------------------------------------------------------------------
; shadow-cljs (select): script
; (out) To quit, type: :cljs/quit
[:selected :script] do you have an actujal node main.js process running is the question?
I thought node-repl would manage it?
yes, it would. but I assume ; shadow-cljs (select): script means that you selected the REPL for the script build
I tried running it now, my test quits immediatly it's just a println, should I put something in there for it to not quit?
this is from conjure, so I'm just guessing
{:source-paths ["src"]
:dependencies [
[cider/cider-nrepl "0.24.0"]
[org.clojure/core.async "1.5.648"]]
:builds {:script {:target :node-script
:output-to "main.js"
:main foo/bar}}}and the output from node main.js?
it runs and prints
it should say shadow-cljs - #<a-number> ready!
with an error after :
foo
SHADOW import error /Users/andrei/dev/shadow-cljs-node/.shadow-cljs/builds/script/dev/out/cljs-runtime/shadow.module.main.append.js
/Users/andrei/dev/shadow-cljs-node/.shadow-cljs/builds/script/dev/out/cljs-runtime/cljs/core.cljs:4014
(if (.-cljs$lang$applyTo f)
ok. so whats the full error?
ok I had to redo some things so now I have:
❯ shadow-cljs node-repl script
shadow-cljs - config: /Users/andrei/dev/shadow-cljs-node/shadow-cljs.edn
WARNING: The org.clojure/core.async dependency in shadow-cljs.edn was ignored. Default version is used and override is not allowed to ensure compatibility.
The versions provided by shadow-cljs can be found here:
shadow-cljs - server version: 2.28.18 running at
shadow-cljs - nREPL server started on port 56327
cljs.user=> shadow-cljs - #4 ready!
:^[WARNING: update-vals already refers to: #'clojure.core/update-vals in namespace: cider.nrepl.inlined-deps.orchard.v0v5v6.orchard.misc, being replaced by: #'cider.nrepl.inlined-deps.orchard.v0v5v6.orchard.misc/update-vals
WARNING: update-keys already refers to: #'clojure.core/update-keys in namespace: cider.nrepl.inlined-deps.orchard.v0v5v6.orchard.misc, being replaced by: #'cider.nrepl.inlined-deps.orchard.v0v5v6.orchard.misc/update-keys
❯ shadow-cljs watch script
shadow-cljs - config: /Users/andrei/dev/shadow-cljs-node/shadow-cljs.edn
shadow-cljs - connected to server
shadow-cljs - watching build :script
[:script] Configuring build.
[:script] Compiling ...
[:script] Build completed. (87 files, 0 compiled, 0 warnings, 0.40s)
and in Conjure:
; localhost:56327 (connected): /Users/andrei/dev/shadow-cljs-node/.shadow-cljs/nrepl.port
; --------------------------------------------------------------------------------
; Assumed session: Belgian Sheepdog (Unknown
; --------------------------------------------------------------------------------
; shadow-cljs (select): script
; (err) No available JS runtime.
; (err) See port is correct
ok. you are obviously confused and doing two things that are entirely unrelated to each other
shadow-cljs node-repl script is not a command. the script argument does absolutely nothing
shadow-cljs node-repl is a standalone node REPL that is not tied to any build. you can start it without any build config active at all
i thought it was supposed to run the script build by that target
ok
shadow-cljs (select): script I guess means that you didn't select the node-repl and instead want to talk to a REPL for your script build
that is completely separate and has nothing to do with node-repl
ok I've launched just node-repl
so you do either one, not both
ok. that drops you right into the REPL
I cannot tell you how that works from the conjure side, or whether that works at all, but the terminal thing should be working just fine
From the Conjure docs:
To switch over to evaluating in our browser (or other JavaScript environment depending on your configuration) we must use :ConjureShadowSelect [build name] from within Neovim like so.
:ConjureShadowSelect app
ok
ok, so that would then be :ConjureShadowSelect node-repl
just $ shadow-cljs node-repl doesn't give me a REPL
that isn't right, right?
hmm you just pasted that it did?
❯ shadow-cljs node-repl script
shadow-cljs - config: /Users/andrei/dev/shadow-cljs-node/shadow-cljs.edn
WARNING: The org.clojure/core.async dependency in shadow-cljs.edn was ignored. Default version is used and override is not allowed to ensure compatibility.
The versions provided by shadow-cljs can be found here:
shadow-cljs - server version: 2.28.18 running at
shadow-cljs - nREPL server started on port 56327
cljs.user=> shadow-cljs - #4 ready! THANK YOU
this is it
the prompt is a bit garbled but it is there
ok so this seems to work, I don't get why [build name] is somehow node-repl
on the Conjure side
because shadow-cljs node-repl creates an implicit build named node-repl, one that is managed by shadow-cljs
ah got it
right ok the other option being make my own build and launch with node
yes, that would connect you to the node process you launch
(but if that crashes or exits early then obviously you can't connect to it)
yeah this works well, thank you, this gets me as far as I wanted
After reading the docs I set up my shadow-cljs.edn like this
{:source-paths ["src"]
:dependencies [
[cider/cider-nrepl "0.24.0"]
[org.clojure/core.async "1.5.648"]]
:builds {:script {:target :node-script
:output-to "main.js"
:main foo}}}
and now I get "No available JS runtime." when eval-ing
it also fails to compile
[:script] Compiling ...
Invalid configuration
-- Spec failed --------------------
{:target ...,
:output-to ...,
:main foo,
^^^
:build-id ...}
should satisfy
unquoted-qualified-symbol?
in src/foo.cljs:
(ns foo
(:require ["fs" :as fs]))its not an ns, its a function you want to run
so (defn main [& args] ...) and then :main foo/main
Thank you:! believe it or not i just realized it literally 1 second before i heard the notification sound 😄
"No available JS runtime" means that the created script is not running
if you just want a node-repl use shadow-cljs node-repl, build not required for that
I think you did telepathy 🙂
what do you mean by that command?
a REPL needs a place where the eval is actually executed
I want to use it from Conjure
by default there is no running node process, so you create one. either by running your script or by launching a node-repl
see other thread
that's a very old cider-nrepl btw