Clojurescript error in luminus

I have a test project in luminus that was created with the following code:

lein new luminus test +sqlite +reagent +graphql

project.clj:

(defproject test "0.1.0-SNAPSHOT"

  :description "FIXME: write description"
  :url "http://example.com/FIXME"

  :dependencies [[ch.qos.logback/logback-classic "1.2.10"]
                 [cljs-ajax "0.8.4"]
                 [clojure.java-time "0.3.3"]
                 [com.cognitect/transit-clj "1.0.329"]
                 [com.cognitect/transit-cljs "0.8.269"]
                 [com.walmartlabs/lacinia "0.32.0"]
                 [conman "0.9.3"]
                 [cprop "0.1.19"]
                 [expound "0.9.0"]
                 [funcool/struct "1.4.0"]
                 [json-html "0.4.7"]
                 [luminus-migrations "0.7.1"]
                 [luminus-transit "0.1.5"]
                 [luminus-undertow "0.1.14"]
                 [luminus/ring-ttl-session "0.3.3"]
                 [markdown-clj "1.10.8"]
                 [metosin/muuntaja "0.6.8"]
                 [metosin/reitit "0.5.15"]
                 [metosin/ring-http-response "0.9.3"]
                 [mount "0.1.16"]
                 [nrepl "0.9.0"]
                 [org.clojure/clojure "1.10.3"]
                 [org.clojure/clojurescript "1.11.4" :scope "provided"]
                 [org.clojure/core.async "1.5.648"]
                 [org.clojure/data.json "0.2.6"]
                 [org.clojure/tools.cli "1.0.206"]
                 [org.clojure/tools.logging "1.2.4"]
                 [org.webjars.npm/bulma "0.9.3"]
                 [org.webjars.npm/material-icons "1.0.0"]
                 [org.webjars/webjars-locator "0.42"]
                 [org.webjars/webjars-locator-jboss-vfs "0.1.0"]
                 [org.xerial/sqlite-jdbc "3.36.0.3"]
                 [reagent "1.1.0"]
                 [ring-webjars "0.2.0"]
                 [ring/ring-core "1.9.5"]
                 [ring/ring-defaults "0.3.3"]
                 [selmer "1.12.50"]
                 [thheller/shadow-cljs "2.17.0" :scope "provided"]]

  :min-lein-version "2.0.0"
  
  :source-paths ["src/clj" "src/cljs" "src/cljc"]
  :test-paths ["test/clj"]
  :resource-paths ["resources" "target/cljsbuild"]
  :target-path "target/%s/"
  :main ^:skip-aot test.core

  :plugins [] 
  :clean-targets ^{:protect false}
  [:target-path "target/cljsbuild"]
  

  :profiles
  {:uberjar {:omit-source true
             
             :prep-tasks ["compile" ["run" "-m" "shadow.cljs.devtools.cli" "release" "app"]]
             :aot :all
             :uberjar-name "test.jar"
             :source-paths ["env/prod/clj"  "env/prod/cljs" ]
             :resource-paths ["env/prod/resources"]}

   :dev           [:project/dev :profiles/dev]
   :test          [:project/dev :project/test :profiles/test]

   :project/dev  {:jvm-opts ["-Dconf=dev-config.edn" ]
                  :dependencies [[binaryage/devtools "1.0.4"]
                                 [cider/piggieback "0.5.3"]
                                 [org.clojure/tools.namespace "1.2.0"]
                                 [pjstadig/humane-test-output "0.11.0"]
                                 [prone "2021-04-23"]
                                 [ring/ring-devel "1.9.5"]
                                 [ring/ring-mock "0.4.0"]]
                  :plugins      [[com.jakemccrary/lein-test-refresh "0.24.1"]
                                 [jonase/eastwood "0.3.5"]
                                 [cider/cider-nrepl "0.26.0"]] 
                  
                  
                  :source-paths ["env/dev/clj"  "env/dev/cljs" "test/cljs" ]
                  :resource-paths ["env/dev/resources"]
                  :repl-options {:init-ns user
                                 :timeout 120000}
                  :injections [(require 'pjstadig.humane-test-output)
                               (pjstadig.humane-test-output/activate!)]}
   :project/test {:jvm-opts ["-Dconf=test-config.edn" ]
                  :resource-paths ["env/test/resources"] 
                  
                  
                  }
   :profiles/dev {}
profiles/test {}})

shadow.edn:

{:nrepl {:port 7002}
 :builds
        {:app
               {:target     :browser
                :output-dir "target/cljsbuild/public/js"
                :asset-path "/js"
                :modules    {:app {:entries [test.app]}}
                
                :release    {}}
         :test {:target  :node-test, :output-to "target/test/test.js"
                :autorun true}}
 `:lein  {:profile "+dev"}}`

when I try to start the webserver with lein run

I get the following error:

#### Welcome to test

If you're seeing this message, that means you haven't yet compiled your ClojureScript!

Please run `shadow-cljs watch app` to start the ClojureScript compiler and reload the page.

I’ve tried a lot of things but with no succes. includng running shadow … from the commandline. any ideas?

lein run will only start the Clojure process and not the clojurescript compiler/file watcher. as the error says…

https://luminusweb.com/docs/clojurescript.html#running_the_compiler

This should help.

I tried this according to your link: :npx shadow-cljs watch app

and got this:

shadow-cljs - config: /Users/jonas/Dropbox/prog/web/clojure/luminus/test/shadow-cljs.edn
shadow-cljs - running: lein with-profile +dev run -m shadow.cljs.devtools.cli --npm watch app
Executable 'lein' not found on system path.

I can somehow get around this problem by running:

lein with-profile +dev run -m shadow.cljs.devtools.cli --npm watch app

but is should be running as npx shadow-cljs watch app according to the homepage

I feel it has something to do with how your system is setup…

That is probably right. But where do you set the lein path in the shadow-cljs.edn file?

I’m not knowledgeable on shadow-cljs internals… However, assuming you’re on a Mac…

Where is your lein script installed? What is your shell? What is your $PATH? How did you install npm/node?

well lein is set in bash_profile but I suspekt that shadow-cljs is looking in either project.cls or shadow-cljs.edn but I cannot find anything on that.
But it is strange that clojurescript support is badly supported in luminus. When following the officical dokumentation and “web development with clojure” it all reads that using lein arguments +cljs should be enough.

Not enough details to help troubleshoot. I didn’t run into any of these issues, with the lein script installed via brew or port, or even manually downloaded and installed in /usr/local/bin. macOS or Linux.

ok, this is what I have done to temporarily solve this:

First install in the test dir:

npm install react react-dom create-react-class

then run lein directly:

lein with-profile +dev run -m shadow.cljs.devtools.cli --npm watch app

so it is not suppose to be like this, but this is the closest that I get.

FYI, normally what I do -

lein new luminus appname -- +shadow-cljs +re-frame ... etc
cd appname
npm install

Seems like I have shadow-cljs installed globally via npm install -g shadow-cljs but I also see the shadow-cljs script is located in appname/node_modules/.bin/

That last npm install command is important as it will install all the required cljs/react/shadow deps in the app’s node_modules directory and allow running shadow and allow compiling the cljs app at all.

I’l also note that I used +shadow-cljs in my lein new command, while your previous example a few days ago only had +cljs.

From there, I usually run the repl from emacs or vscode which starts up all the processes for me, but this also works:

npx shadow-cljs watch app

and separately

lein run

OR

lein repl

To start the main clj app as well.

I have lein, npm, clojure, node all installed via macports so they all reside under /opt/local/, but it shouldn’t be sensibly different if installed via homebrew or other means.

I think shadow-clsj is installed by default by +reagent

But following your commands did not work, I had to do with

npm install react react-dom create-react-class

and

lein with-profile +dev run -m shadow.cljs.devtools.cli --npm watch app

this could be a mac thing, I can try it later on my ubuntu computer

I’m on a Mac too. AFAIK +reagent does not guarantee shadow-cljs (unless things changed since I read the book). Either way when I create the new Luminux project there’s definitely a package.json file with those dependencies included in them.

I just tested with +reagent only, and indeed it had shadow.clj as a dep and created a package.json that looks like:

{
  "devDependencies": {
    "shadow-cljs": "^2.16.5"
  },
  "dependencies":{
    "react": "^17.0.2",
    "react-dom": "^17.0.2"
  }
}

Making it easy for me to run npm install and get all the deps installed in the node_modules directory.

 /tmp> lein new luminus appname2 -- +reagent
Generating a Luminus project.
 /tmp> cd appname2
/t/appname2> uname -a
Darwin ******* 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:47:26 PDT 2022; root:xnu-8020.101.4~15/RELEASE_ARM64_T8101 arm64
 /t/appname2> ls
Capstanfile      Procfile         dev-config.edn   package.json     resources/       src/             test-config.edn
Dockerfile       README.md        env/             project.clj      shadow-cljs.edn  test/
 /t/appname2> cat package.json
{
  "devDependencies": {
    "shadow-cljs": "^2.16.5"
  },
  "dependencies":{
    "react": "^17.0.2",
    "react-dom": "^17.0.2"
  }
}

patrix@Selentium /t/appname2> ls
Capstanfile      Procfile         dev-config.edn   package.json     resources/       src/             test-config.edn
Dockerfile       README.md        env/             project.clj      shadow-cljs.edn  test/
patrix@Selentium /t/appname2> npm install
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.

added 98 packages, and audited 99 packages in 3s

3 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
 /t/appname2> ./node_modules/.bin/shadow-cljs watch app
shadow-cljs - config: /private/tmp/appname2/shadow-cljs.edn
shadow-cljs - running: lein with-profile +dev run -m shadow.cljs.devtools.cli --npm watch app
2022-04-25 21:23:56,033 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider
2022-04-25 21:23:56,383 [main] INFO  io.undertow - starting server: Undertow - 2.2.14.Final
2022-04-25 21:23:56,387 [main] INFO  org.xnio - XNIO version 3.8.4.Final
2022-04-25 21:23:56,442 [main] INFO  org.jboss.threads - JBoss Threads version 3.1.0.Final
2022-04-25 21:23:56,449 [main] DEBUG io.undertow - Configuring listener with protocol HTTP for interface 0.0.0.0 and port 9630
shadow-cljs - server version: 2.17.0 running at http://localhost:9630
shadow-cljs - nREPL server started on port 7002
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (274 files, 273 compiled, 0 warnings, 8.93s)

So I replicated all steps:

jonas@Jonass-MBP:~/Dropbox/prog/web/clojure/luminus$ lein new luminus test3 +reagent +sqlite
Generating a Luminus project.
jonas@Jonass-MBP:~/Dropbox/prog/web/clojure/luminus$ cd test3/
jonas@Jonass-MBP:~/Dropbox/prog/web/clojure/luminus/test3$ uname -a
Darwin Jonass-MBP 18.7.0 Darwin Kernel Version 18.7.0: Mon Feb 10 21:08:45 PST 2020; root:xnu-4903.278.28~1/RELEASE_X86_64 x86_64
jonas@Jonass-MBP:~/Dropbox/prog/web/clojure/luminus/test3$ cat package.json 
{
  "devDependencies": {
    "shadow-cljs": "^2.16.5"
  },
  "dependencies":{
    "react": "^17.0.2",
    "react-dom": "^17.0.2"
  }
}
jonas@Jonass-MBP:~/Dropbox/prog/web/clojure/luminus/test3$ npm install
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.

added 98 packages, and audited 99 packages in 8s

3 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

jonas@Jonass-MBP:~/Dropbox/prog/web/clojure/luminus/test3$ shadow-cljs watch app
shadow-cljs - config: /Users/jonas/Dropbox/prog/web/clojure/luminus/test3/shadow-cljs.edn
shadow-cljs - running: lein with-profile +dev run -m shadow.cljs.devtools.cli --npm watch app
Executable 'lein' not found on system path.
jonas@Jonass-MBP:~/Dropbox/prog/web/clojure/luminus/test3$ ./node_modules/.bin/shadow-cljs watch app
shadow-cljs - config: /Users/jonas/Dropbox/prog/web/clojure/luminus/test3/shadow-cljs.edn
shadow-cljs - running: lein with-profile +dev run -m shadow.cljs.devtools.cli --npm watch app
Executable 'lein' not found on system path.

so same error.

but running lein directly works:

jonas@Jonass-MBP:~/Dropbox/prog/web/clojure/luminus/test3$  lein with-profile +dev run -m shadow.cljs.devtools.cli --npm watch app
2022-04-25 19:45:52,669 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider 
2022-04-25 19:46:23,687 [main] INFO  io.undertow - starting server: Undertow - 2.2.14.Final 
2022-04-25 19:46:23,698 [main] INFO  org.xnio - XNIO version 3.8.4.Final 
2022-04-25 19:46:23,859 [main] INFO  org.jboss.threads - JBoss Threads version 3.1.0.Final 
2022-04-25 19:46:23,872 [main] DEBUG io.undertow - Configuring listener with protocol HTTP for interface 0.0.0.0 and port 9630 
shadow-cljs - server version: 2.17.0 running at http://localhost:9630
shadow-cljs - nREPL server started on port 7002
shadow-cljs - watching build :app
[:app] Configuring build.
[:app] Compiling ...
[:app] Build completed. (274 files, 273 compiled, 0 warnings, 40,77s)

I don’t know why shadow… cannot find lein

Alright, so we’re back to my response from 7 days ago, how is lein setup/installed on your system? What directory does it reside in? I wonder if there’s some location that’s in your $PATH in your shell, but not in whatever $PATH that npm uses when running…

ok, I looked after a path variable to set but could not find one. So I simply copied lein from ~/bin/lein (my home dir) to /usr/local/bin and now it found it and it works. Thanks for the answers.

Whew! Glad it was something simple enough in the end!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.