Fork me on GitHub
#shadow-cljs
<
2023-06-07
>
Drew Verlee02:06:38

How do you interpret this error, and what should I do about it? (see below) What I see is that my package.json has the version mentioned in the error "highlight.js": "^9.12.0" and the error is that it can't compare that to another version. but i dont' see where the 9.15.10 is coming from or understand why it's trying to compare to it. I tried yarn clean bc who doesn't love a good clean yarn... not sure what else to try

[:failed-to-compare "^9.12.0" "9.15.10" #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__16957$fn__16958 invoke "npm_deps.clj" 46]
  [clojure.lang.Delay deref "Delay.java" 42]
  [clojure.core$deref invokeStatic "core.clj" 2337]
  [clojure.core$deref invoke "core.clj" 2323]
  [shadow.cljs.devtools.server.npm_deps$fn__16957$fn__16960 invoke "npm_deps.clj" 52]
  [shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_ invokeStatic "npm_deps.clj" 207]
  [shadow.cljs.devtools.server.npm_deps$is_installed_QMARK_ invoke "npm_deps.clj" 201]
  [shadow.cljs.devtools.server.npm_deps$main$fn__17046 invoke "npm_deps.clj" 223]
  [clojure.core$complement$fn__5737 invoke "core.clj" 1455]
  [clojure.core$filter$fn__5962 invoke "core.clj" 2838]
  [clojure.lang.LazySeq sval "LazySeq.java" 42]
  [clojure.lang.LazySeq seq "LazySeq.java" 51]
  [clojure.lang.RT seq "RT.java" 535]
  [clojure.core$seq__5467 invokeStatic "core.clj" 139]
  [clojure.core$seq__5467 invoke "core.clj" 139]
  [shadow.cljs.devtools.server.npm_deps$main invokeStatic "npm_deps.clj" 225]
  [shadow.cljs.devtools.server.npm_deps$main invoke "npm_deps.clj" 216]
  [shadow.cljs.devtools.cli$main invokeStatic "cli.clj" 143]
  [shadow.cljs.devtools.cli$main doInvoke "cli.clj" 134]
  [clojure.lang.RestFn applyTo "RestFn.java" 137]
  [clojure.core$apply invokeStatic "core.clj" 671]
  [clojure.core$apply invoke "core.clj" 662]
  [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" 667]
  [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]]}]
Here is my shadow info
➜  centriq-immobile git:(staging) ✗ npx shadow-cljs info     
shadow-cljs - config: /home/drewverlee/centriq/centriq-immobile/shadow-cljs.edn  cli version: 2.8.67  node: v12.3.1
=== Version
jar:            2.8.67
cli:            2.8.67
deps:           1.3.1
config-version: 2.8.67

=== Paths
cli:     /home/drewverlee/centriq/centriq-immobile/node_modules/shadow-cljs/cli/dist/shadow.cljs.npm.cli.js
config:  /home/drewverlee/centriq/centriq-immobile/shadow-cljs.edn
project: /home/drewverlee/centriq/centriq-immobile
cache:   .shadow-cljs

=== Java
openjdk version "17.0.7" 2023-04-18
OpenJDK Runtime Environment (build 17.0.7+7-Ubuntu-0ubuntu122.04.2)
OpenJDK 64-Bit Server VM (build 17.0.7+7-Ubuntu-0ubuntu122.04.2, mixed mode, sharing)

=== Source Paths
(I'm trying to update, but there some minor blockers) There is a remark that this "kind" of error is fixed in 2.8.5 but were past that.

dpsutton02:06:15

does your shadow-cljs.edn specify a target? :target :npm-module

Drew Verlee02:06:58

:target :browser

Drew Verlee02:06:59

there is also this within the build that i haven't had time to parse:

:js-options {:variable-renaming :local
              :resolve {"cross-fetch/polyfill" {:target :npm
                                                 :require "unfetch"}}}

Drew Verlee02:06:49

Heres a remark that the error is best fixed by updating shadow-cljs

benji11:06:09

Quick question (first post!) … with this example shadow-cljs.edn config:-

{:lein  true
 :nrepl {:port 8888}
 :cache-root "/tmp/.shadow-cljs"
 :builds {:my-target {:target :node-library
                      :output-to "../some/folder/index.js"
                      :exports {:my-export-1 ns/fn-1
                                :my-export-2 ns/fn-2}
                      :compiler-options {:infer-externs :auto}
                      :release {}}}}
I can’t quite work out why my exports are being renamed, in that the dashes are being renamed to underscores i.e., my-export-1 is being renamed to my_export_1 etc. It’s not a biggie, but just curious as to what might be doing it as shadow isn’t meant to change these?

thheller11:06:15

exports need to follow JS conventions, so my-export-1 would be my minus export minus 1 in JS and not a valid identifier

thheller11:06:28

they are "munged" as to avoid generating invalid code. I guess it could throw instead but there are not - in JS identifiers, so it is doing what is needed

thheller11:06:29

FWIW I strongly recommend not setting a global :cache-root "/tmp/.shadow-cljs". that can lead to problems if you have multiple projects doing that

benji11:06:43

that’s totally fine, thanks for the clarification 🙂 … my misunderstanding and I’ll stop setting a global :cache-root … the project is quite old and needs a little love 🙂