Clojurescript libraries - goog.require could not find
Asked Answered
L

6

6

New to clojurescript, and working through the "Modern CLJS" tutorial here.

It instructs to pull in domina by adding it to the project.clj:

:dependencies [[org.clojure/clojure "1.4.0"]
               [compojure "1.1.5"]
               [domina "1.0.0"]]

And then use it in your script by referencing it in the ns form

(ns cljstut.login
  (:use [domina :only [by-id value]]))

However, when I actually run this in a browser, I see the following in the console log.

goog.require could not find: domina

Seems like I'm missing some declaration somewhere? But as a newb, this whole build process is rather opaque. Any troubleshooting tips are greatly appreciated.

Lyndalynde answered 25/2, 2013 at 1:35 Comment(0)
J
3

Dependencies in your project.clj file and your namespace declarations look fine.

If you are building your clojurescript code using lein cljsbuild auto, you will need to restart that process. I believe it should automatically pull in new dependencies after a restart.

If that doesn't work, or you aren't using lein cljsbuild auto, try running the lein deps command inside your project's folder manually - it will fetch all missing dependencies from remote repositories.

Jumada answered 25/2, 2013 at 4:50 Comment(3)
I've actually just gotten through this, and I think it may have been domina 1.0.1 that fixed it? Something about goog-jar or something was a dependency in 1.0.0 and it no longer takes that. Does that seems reasonable?Lyndalynde
Ah yes, that makes sense. I believe with domina 1.0.0 you had to add an explicit dependency on the google clojure third party lib in order to make things work.Jumada
Restarting lein cljsbuild auto worked for me for a similar error.Caucasian
D
3

Also, make sure you have saved your project.clj file and try running lein clean and lein cljsbuild clean.

Diseased answered 28/3, 2014 at 12:49 Comment(0)
G
1

I'm in the process of updating modern-cljs to the latest versions of the used libs and lein plugins. At the moment I updated the series up to the 7th tutorial of the series. You should now be safe by updating to domina 1.0.2-SNAPSHOT into project.cljs :dependencies and to lein-cljsbuild 0.3.0 into project.cljs :plugins.

Mimmo

Gusher answered 3/3, 2013 at 16:15 Comment(0)
G
1

Just want to add that a typo in the namespace would trigger the same error message:

goog.require could not find: domina

Example (note the missing "j" in modern-cljs):

(ns modern-cls.login
  (:use [domina :only [by-id value]]))

I was using a different project name thus a different namespace just to be brave. It bit me in the ass when I copy-pasted from the guide and the error had me puzzled for a while :)

Gardy answered 10/9, 2013 at 20:0 Comment(0)
B
0

I ran into this same issue while working through the "Modern CLJS" tutorial. My problem was inadvertently adding the "domina" dependency to the :plugins section of project.clj rather than the :dependencies section.

Bores answered 12/7, 2015 at 19:50 Comment(0)
A
0

I got past this error message by putting lines in the right order in the index.html file.

Correct order:

<script src="js/expanding_gases.js" type="text/javascript"></script>
<script type="text/javascript">goog.require("expanding_gases.flow_gases");</script>

Incorrect order:

<script type="text/javascript">goog.require("expanding_gases.flow_gases");</script>
<script src="js/expanding_gases.js" type="text/javascript"></script>

By the way a good read for understanding 'goog' messages is here: https://github.com/clojure/clojurescript/wiki/Quick-Start

Ainslie answered 14/10, 2015 at 21:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.