Search code examples
clojurescriptfigwheel

How to resolve Uncaught TypeError: clojure is undefined


I have done something to my clojurescript project which produces this error, I am using figwheel-main with deps.edn, not really sure what to look for to resolve this it sounds like clojurescript itself is not being found when run in a browser

Uncaught TypeError: clojure is undefined
    option_values_fmt http://localhost:9500/cljs-out/main.js:3842
    cljs$core$IReduce$_reduce$arity$3 http://localhost:9500/cljs-out/main.js:2534
    cljs$core$IFn$_invoke$arity$3 http://localhost:9500/cljs-out/main.js:1626
    reduce http://localhost:9500/cljs-out/main.js:1623
    option_values_fmt http://localhost:9500/cljs-out/main.js:3842
    <anonymous> http://localhost:9500/cljs-out/main.js:3850

my figwheel file looks like this, one fo the changes I have made is to put a lot of the requirements in :extra-deps insteads of under :deps clojurescript and clojure are still included at the root.

{:output-to "resources/public/cljs-out/main.js"
 :optimizations :none
 ;:pseudo-names true
 :pretty-print true
 :source-map true
 :source-map-timestamp true
 :devcards true
 :main webpage.core}

What should I look for that might cause this error ?


Solution

  • Most likely this is a problem somewhere in your code, not your dependencies.

    This for example can happen if you use a fully qualified reference (eg. (clojure.string/anything ...)) without having required the referenced namespace properly beforehand (ie. (:require [clojure.string ...]) in your ns form). The require ensures that the code is actually loaded and available before your code executes.