尝试运行简单的hello world的.js输出时,得到“无法设置属性undefined的错误”clojurescript

我正在编译:

(ns example.hello) (js/console.log "Hello from ClojureScript!") 

有了这个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 }}]}) 

哪个输出的文件太大而不能放在这里,但是会给出错误:

 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) 

那么,在你给的项目configuration中,你的:optimizations :simple子句被注释掉了。 这意味着它不会有任何Google Closure优化,这意味着输出的JavaScript 不会被放在一个足够的文件中,而是被分解成许多文件。 这也意味着你必须明确包含来自Google Closure库的base.js

看起来就是这里发生了什么事,虽然可能还有其他的东西在发生……我实际上并不熟悉ClojureScript的node.js输出。

错误已经通过重新安装leiningen和干净的构build来解决。