Hello, I’m very new in shadow-cljs. I encounter a problem recently that I’m getting a ton of errors like these after invoke watch
command. The compilation still works, but that’s making the console unusable.
[:failed-to-compare "^7.8.7" "7.12.5" #error {
:cause "Cannot invoke \"Object.getClass()\" because \"target\" is null"
:via
[{:type java.lang.NullPointerException
:message "Cannot invoke \"Object.getClass()\" because \"target\" is null"
:at [clojure.lang.Reflector invokeInstanceMethod "Reflector.java" 97]}]
:trace
[[clojure.lang.Reflector invokeInstanceMethod "Reflector.java" 97]
[shadow.cljs.devtools.server.npm_deps$make_engine invokeStatic "npm_deps.clj" 39]
[shadow.cljs.devtools.server.npm_deps$make_engine invoke "npm_deps.clj" 32]
[shadow.cljs.devtools.server.npm_deps$fn__17481$fn__17482 invoke "npm_deps.clj" 46]
[clojure.lang.Delay deref "Delay.java" 42]
[clojure.core$deref invokeStatic "core.clj" 2320]
[clojure.core$deref invoke "core.clj" 2306]
[shadow.cljs.devtools.server.npm_deps$fn__17481$fn__17484 invoke "npm_deps.clj" 52]
[shadow.build.targets.browser$check_npm_versions$fn__18133$fn__18134 invoke "browser.clj" 826]
[clojure.core.protocols$iter_reduce invokeStatic "protocols.clj" 49]
[clojure.core.protocols$fn__8138 invokeStatic "protocols.clj" 75]
[clojure.core.protocols$fn__8138 invoke "protocols.clj" 75]
[clojure.core.protocols$fn__8088$G__8083__8101 invoke "protocols.clj" 13]
[clojure.core$reduce invokeStatic "core.clj" 6828]
[clojure.core$reduce invoke "core.clj" 6810]
[shadow.build.targets.browser$check_npm_versions$fn__18133 invoke "browser.clj" 818]
[shadow.build.targets.browser$check_npm_versions invokeStatic "browser.clj" 817]
[shadow.build.targets.browser$check_npm_versions invoke "browser.clj" 799]
[shadow.build.targets.browser$process invokeStatic "browser.clj" 854]
[shadow.build.targets.browser$process invoke "browser.clj" 838]
[clojure.lang.Var invoke "Var.java" 384]
[shadow.build$process_stage$fn__14212 invoke "build.clj" 148]
[shadow.build$process_stage invokeStatic "build.clj" 145]
[shadow.build$process_stage invoke "build.clj" 137]
[shadow.build$compile invokeStatic "build.clj" 408]
[shadow.build$compile invoke "build.clj" 397]
[shadow.cljs.devtools.api$release_STAR_ invokeStatic "api.clj" 353]
[shadow.cljs.devtools.api$release_STAR_ invoke "api.clj" 340]
[shadow.cljs.devtools.cli$do_build_command invokeStatic "cli.clj" 29]
[shadow.cljs.devtools.cli$do_build_command invoke "cli.clj" 26]
[shadow.cljs.devtools.cli$do_build_commands invokeStatic "cli.clj" 51]
[shadow.cljs.devtools.cli$do_build_commands invoke "cli.clj" 40]
[shadow.cljs.devtools.cli$main$body_fn__17101__auto____17691 invoke "cli.clj" 168]
[shadow.cljs.devtools.cli$main invokeStatic "cli.clj" 167]
[shadow.cljs.devtools.cli$main doInvoke "cli.clj" 134]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.core$apply invokeStatic "core.clj" 669]
[clojure.core$apply invoke "core.clj" 660]
[shadow.cljs.devtools.cli$_main invokeStatic "cli.clj" 221]
[shadow.cljs.devtools.cli$_main doInvoke "cli.clj" 219]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.core$apply invokeStatic "core.clj" 665]
[clojure.main$main_opt invokeStatic "main.clj" 514]
[clojure.main$main_opt invoke "main.clj" 510]
[clojure.main$main invokeStatic "main.clj" 664]
[clojure.main$main doInvoke "main.clj" 616]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.main main "main.java" 40]]}]
I google for hours and no result, I’m curious is there a way for me to debug the process of compilation. Thanks very much.clojure -M:cljs watch app
, I use this command. Thank you all the same, Your help may lead me to find a solution : )
I saw these messages about 1 or 2 days ago.
I just advise you to go through git diff what broke it
going through change by change, pin point what change broke it 🙂
Thanks for your advice. I reset the codebase, but did not work. I guess something broken out the codebase.
I found it was a problem with jdk. It works when I downgrade jdk from 15 to 1.8. Thanks for your help @wontheone1: )
Aha no problem
I think JDK 8 is the most stable version with Clojure 🙂
Good that you found out!
I recall that I executed brew upgrade
unconsciously yesterday 😭
😄 brew fucked up my python environments few times as well
what does your shadow-cljs.edn look like?
@wontheone1 It may be a bit verbose. I use deps.edn with shadow-cljs. the deps.edn:
{:paths ["src/main"]
:deps
{org.clojure/clojure {:mvn/version "1.10.1"}
rum/rum {:mvn/version "0.12.3"}
;; rum {:local/root "/home/tienson/codes/source/clj/rum"}
;; persistent-sorted-set {:mvn/version "0.1.2"}
;; FIXME: doesn't work on my archlinux laptop (tienson)
;; The required namespace "datascript.core" is not available, it was required by "frontend/db.cljs".
datascript/datascript {:git/url "<https://github.com/tiensonqin/datascript>",
:sha "7c2822565d9a114c7d8604c335af89de4640e2e5"}
;; datascript {:mvn/version "1.0.1"}
datascript-transit/datascript-transit
{:mvn/version "0.3.0"
:exclusions [datascript]}
funcool/promesa {:mvn/version "4.0.2"}
medley/medley {:mvn/version "1.2.0"}
metosin/reitit-frontend {:mvn/version "0.3.10"}
cljs-bean/cljs-bean {:mvn/version "1.5.0"}
prismatic/dommy {:mvn/version "1.1.0"}
org.clojure/core.match {:mvn/version "1.0.0"}
com.andrewmcveigh/cljs-time {:mvn/version "0.5.2"}
cljs-drag-n-drop/cljs-drag-n-drop
{:mvn/version "0.1.0"}
borkdude/sci {:mvn/version "0.1.1-alpha.6"}
hickory/hickory {:mvn/version "0.7.1"}
hiccups/hiccups {:mvn/version "0.3.0"}
tongue/tongue {:mvn/version "0.2.9"}
org.clojure/core.async {:mvn/version "1.3.610"}
thheller/shadow-cljs {:mvn/version "2.8.81"}
expound/expound {:mvn/version "0.8.6"}
lambdaisland/glogi {:mvn/version "1.0.74"}}
:aliases {:cljs {:extra-paths ["src/dev-cljs/"]
:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.597"}
thheller/shadow-cljs {:mvn/version "2.8.81"}
binaryage/devtools {:mvn/version "0.9.10"}
org.clojure/tools.namespace {:mvn/version "0.2.11"}
cider/cider-nrepl {:mvn/version "0.23.0-SNAPSHOT"}}
:main-opts ["-m" "shadow.cljs.devtools.cli"]}
:test
{:extra-paths ["src/test/"]
:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.520"}
org.clojure/test.check {:mvn/version "RELEASE"}}
:main-opts ["-m" "shadow.cljs.devtools.cli"]}
:runner
{:extra-deps
{com.cognitect/test-runner
{:git/url "<https://github.com/cognitect-labs/test-runner>",
:sha "76568540e7f40268ad2b646110f237a60295fa3c"}},
:main-opts ["-m" "cognitect.test-runner" "-d" "test"]}}}
and the shadow-cljs.
{:deps true
:nrepl {:port 8701}
:builds
{:app
{:target :browser
:module-loader true
:modules {:main {:init-fn frontend.core/init}
:code-editor
{:entries [frontend.extensions.code]
:depends-on #{:main}}}
:output-dir "./static/js"
:asset-path "/static/js"
:release {:asset-path "<https://asset.logseq.com/static/js>"}
:compiler-options {:infer-externs :auto
:output-feature-set :es6
:externs ["datascript/externs.js"
"externs.js"]}
:closure-defines {goog.debug.LOGGING_ENABLED true
frontend.config/GITHUB_APP_NAME #shadow/env "GITHUB_APP2_NAME"}
:devtools
;; before live-reloading any code call this function
{:before-load frontend.core/stop
;; after live-reloading finishes call this function
:after-load frontend.core/start
:preloads [devtools.preload]}}
:test
{:target :node-test
:output-to "static/tests.js"}
:publishing
{:target :browser
:module-loader true
:modules {:main {:init-fn frontend.publishing/init}
:code-editor
{:entries [frontend.extensions.code]
:depends-on #{:main}}}
:output-dir "./static/js/publishing"
:asset-path "/static/js"
:closure-defines {frontend.config/PUBLISHING true
goog.debug.LOGGING_ENABLED true}
:compiler-options {:infer-externs :auto
:output-feature-set :es6
:externs ["datascript/externs.js"
"externs.js"]}
:devtools
;; before live-reloading any code call this function
{:before-load frontend.core/stop
;; after live-reloading finishes call this function
:after-load frontend.core/start
:preloads [devtools.preload]}}}}
do you have :target key in the edn?
Sorry, yes,I have a :target key . app
target is :browser
hmm
did you run compile or watch to build dev version and opened a browser to provide runtime?
When do you get those error messages
yep, I guess it might be caused by some of my environment changed yesterday. The config works well for a long time.
sorry I have no idea
Also when do you see these msgs? what command did you run?
or did you run the build with node
?
@michael.wong upgrade shadow-cljs. then jdk15 is just fine. I use it myself.
this jdk8 recommendation needs to die.
thheller/shadow-cljs {:mvn/version "2.8.81"}
is ancient history by now
as is org.clojure/clojurescript {:mvn/version "1.10.520"}
OK, thanks for advice, We will update the version at some future time. At present I need to ensure that our legacy code runs normally.
do I remember correctly that ReferenceError: $jscomp is not defined
in a release build points towards an issue with polyfills?
yes, $jscomp
is polyfills. thought I fixed all the issues though?
still running it one, but only in production, not doing a local release
we’re on 2.11.5
in this project, let me try upgrading first
bumping to the appropriate :output-feature-set
is always the best option
hmm, still occurring with :output-feature-set
:es8
nevermind, caching is hard…