I'm compiling:
(ns example.hello)
(js/console.log "Hello from ClojureScript!")
With this configuration:
(defproject lein-cljsbuild-example "1.2.3"
:plugins [[lein-cljsbuild "0.2.9"]]
:cljsbuild {
:builds [{
:source-path "src-cljs"
:compiler {
:output-to "war/javascripts/mainz.js" ; default: main.js in current directory
;:optimizations :simple
:target :nodejs
;:pretty-print true
}}]})
Which outputs a file that is too big to put here, but gives the error:
goog.debug.Error = function(opt_msg) {
^
TypeError: Cannot set property 'Error' of undefined
at Object.<anonymous> (/Users/myuser/Clojure/cljstest/war/javascripts/mainz.js:503:18)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
Well, in the project config you give, your :optimizations :simple clause is commented out. This means that it will not have any Google Closure optimizations, meaning that the output JavaScript will not be in one sufficient file, but broken into many files. Which also means you must explicitly include base.js from the Google Closure library.
It looks like that's what's happening here, although there might be other stuff going on as well... I'm actually not that familiar with the node.js output for ClojureScript.
The error has been solved by reinstalling leiningen and doing a clean build.