1

I've been trying to learn how to properly debug ClojureScript. I'm sorry if this is a noob question, maybe it's so noob that no one else ever needs to ask it, but I can't find a direct answer anywhere. I've followed these setup tutorials:

https://github.com/shaunlebron/How-To-Debug-CLJS http://teamcoding.com/blog/2015/03/10/clojurescript/

They both setup a solid environment with a repl, but whenever I execute any code, the output and (more importantly) the errors always show up in the repl and not in the console. The only thing I can get to show up in console is print statements using (enable-console-print!).

I would like everything to show up in the console, no matter what, so that I can use source-maps to identify problem areas.

Thanks guys and gals!

Phylth
  • 368
  • 2
  • 14
  • That first reference is outdated and the second is for Om when Om Next is about to become beta. The current standard way of setting up a cljs development environment is to use Figwheel. For instance see [here](http://stackoverflow.com/questions/34305235/how-to-set-up-the-configuration-in-cursive-for-clojurescript/34308150#34308150). – Chris Murphy Jan 27 '16 at 02:50

1 Answers1

1

Use Figwheel https://github.com/bhauman/lein-figwheel

It is easy to set up and does exactly what you want (errors/warnings will be shown in both a discreet popover and the console of your browser). Figwheel reloads your code when you save your file, which I find to be a far better workflow than using a REPL. I made a short video which shows this style of workflow: https://www.youtube.com/watch?v=pIiOgTwjbes. The video shows quite a few different debugging scenarios, and how to make sense of them. If there is anything not covered, please let me know!

Timothy Pratley
  • 10,586
  • 3
  • 34
  • 63
  • This is similar to what I used in the second tutorial I linked. I didn't specify properly; what I really want is repl evaluations, both output and error, showing up in the console or on the webpage itself. This is especially true for debugging so that I can locate the source of errors. – Phylth Jan 27 '16 at 21:30
  • I feel the need to add that it is a super cool vid you uploaded, very helpful to beginners and, in my case, people who have taken over a year out and aren't up to date with all the packages. – Phylth Jan 27 '16 at 21:33
  • Thanks! I see what you mean. It is a reasonable thing to want. Sadly I don't know of a way to get it. You can (try (bad) (catch :default e (prn e))), but the info it gives isn't very useful at all. Instead of using a REPL I save expressions in my file. (prn (+ 1 2)) in your file outside of any functions, gets evaluated right away and shows up in the console. Debugging this is much easier because you get file line numbers (REPL can't give you that). To me this is better than a REPL, there is nothing a REPL offers me (or maybe I am missing out on something awesome?). – Timothy Pratley Jan 27 '16 at 23:45